docker container run requires at least 1 argument
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Introduction
Running docker container run without specifying an image produces the error "docker container run requires at least 1 argument." This is one of the most common Docker errors newcomers encounter, and the fix is straightforward: you must always provide an image name. This article explains the command syntax, shows practical examples, and covers related mistakes that produce the same or similar errors.
Understanding the Command
docker container run (or its shorthand docker run) creates a new container from an image and starts it. The image name is the one required argument because Docker needs to know which filesystem and configuration to use as the container's base.
The full syntax is:
IMAGEis required. It specifies the base image (for example,nginx,python:3.12, orubuntu:22.04).OPTIONSare optional flags placed before the image name.COMMANDandARG...are optional and override the default command defined in the image.
Basic Examples
Running a simple container
This pulls the ubuntu:22.04 image if it is not already present locally, creates a container, runs the echo command inside it, and then exits.
Running an interactive shell
The -i flag keeps STDIN open, and -t allocates a pseudo-TTY. Together, they give you an interactive shell session inside the container.
Running a background service
This starts an Nginx container in detached mode (-d), maps host port 8080 to container port 80, and gives the container the name my-web.
Running with environment variables
Each -e flag sets an environment variable inside the container. This is the standard way to pass configuration to containerized services.
Common Causes of the Error
Missing image name entirely
Docker interprets the flags but finds no positional argument for the image. Always place the image name after all options.
Placing the image name before options
Docker treats nginx as the image and -d -p 8080:80 as the command to run inside the container. The command fails because there is no -d binary in the Nginx image. Options must come before the image name.
Typos in multi-line commands
When using line continuation with backslashes, a missing backslash causes the shell to execute a partial command.
The shell runs docker container run -d on the first line, which lacks an image argument. Add the backslash after -d to continue the command on the next line.
Confusing docker container run with docker container exec
docker container exec runs a command in an already-running container and requires a container name or ID plus a command. If you accidentally type run when you mean exec, or vice versa, you get unexpected errors.
Useful Flags Reference
Here are commonly used flags for docker container run:
The --rm flag is especially useful during development and testing because it automatically removes the container when it stops, preventing a buildup of exited containers.
Verifying and Managing Containers
After running a container, you can check its status and inspect it.
Common Pitfalls
- Forgetting the image name is the most common cause of the "requires at least 1 argument" error. Double-check that the image name appears after all flags.
- Placing flags after the image name. Docker interprets anything after the image as the command to execute inside the container, not as Docker options.
- Missing backslashes in multi-line shell commands. Each line except the last must end with
\for the shell to treat it as a single command. - Using
docker runanddocker container runinterchangeably is fine, since they are aliases, but mixing them withdocker createanddocker start(which are separate steps) can cause confusion. - Not specifying an image tag defaults to
:latest, which may pull a different version than expected. Pin your image versions in production.
Summary
The "docker container run requires at least 1 argument" error means you forgot to specify an image name. The fix is to include the image as the first positional argument after all options. Remember that options go before the image name, the command to run inside the container goes after it, and multi-line commands need proper backslash continuation. Use docker container ls -a to check your containers and --rm to auto-clean during development.
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 Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.