Docker: 'docker run' requires at least 1 argument (error fix)
Codemia Knowledge Hub ·
The error "docker container run requires at least 1 argument" means you ran docker container run without an image name. Every run needs an image, placed after all the options: docker container run [OPTIONS] IMAGE [COMMAND].
The command syntax
docker container run (shorthand docker run) creates a container from an image and starts it. The image is the one required argument, because Docker needs to know which filesystem and configuration to base the container on.
IMAGEis required. It names the base image (for examplenginx,python:3.12orubuntu:22.04).OPTIONSare optional flags and go before the image name.COMMANDandARG...are optional and override the image's default command.
What causes the error
No image name at all
Docker parses the flags but finds no positional argument for the image. Always put the image name after all options.
Image name before the options
Docker takes nginx as the image and -d -p 8080:80 as the command to run inside the container. That fails because the Nginx image has no -d binary. Options must come before the image.
A missing backslash in a multi-line command
With line continuations, a missing backslash makes the shell run a partial command:
The shell runs docker container run -d on its own, with no image. Add the backslash after -d so the command continues on the next line:
Mixing up run and exec
docker container exec runs a command in a container that is already running and needs a container name or ID plus a command. Typing run when you mean exec, or the reverse, gives unexpected errors.
Working examples
A simple container
Docker pulls ubuntu:22.04 if it isn't present locally, creates a container, runs echo in it, and exits.
An interactive shell
-i keeps STDIN open and -t allocates a pseudo-TTY, which together give you an interactive shell in the container.
A background service
This starts Nginx in detached mode (-d), maps host port 8080 to container port 80, and names the container my-web.
Environment variables
Each -e sets an environment variable in the container, the standard way to pass configuration to containerized services.
Other useful flags
--rm is especially handy in development and testing: it removes the container when it stops, so exited containers don't pile up.
Checking and managing containers
Related gotchas
docker runanddocker container runare aliases, so either works. Don't confuse them withdocker createanddocker start, which are separate steps.- Leaving out the image tag defaults to
:latest, which may pull a different version than you expect. Pin image versions in production.
Related reading
- Docker container shuts down giving 'data directory has wrong ownership' error when executed in windows 10
- Docker container will automatically stop after docker run -d
- Docker container Windows, connect via RDP or VNC Client
- Docker desktop - kubernetes failed to start
- Docker Desktop for Windows always getting stuck on extracting
- Docker does not free memory after creating and deleting files with PHP
- Docker Desktop WSL ext4.vhdx too large
- Docker Detached Mode
System design interview problems on this topic
- Design a Container Orchestration System: solution and walkthrough
- Design a Code Deployment System: solution and walkthrough
- Design GitHub Actions: solution and walkthrough
- Design a Serverless Architecture Framework: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.