Difference Between Running and Starting a Docker Container
TLDR
docker run creates and starts a new container from an image, while docker start restarts an existing, stopped container. Use run for new containers, and start to bring back a container you previously stopped.
What Does docker run Do?
docker run is the main command to create and launch a new container. It does several things at once:
- Creates a new container from the specified image
- Assigns it a unique ID and (optionally) a name
- Sets up networking, storage, and environment variables
- Starts the container's main process
Example:
docker run -d --name my-nginx -p 8080:80 nginx
This creates a new container named my-nginx from the nginx image and starts it in the background.
What Does docker start Do?
docker start is used to restart a container that was previously created (and stopped). It does not create a new container or change its configuration.
Example:
docker stop my-nginx # Stop the container
# ... do something ...
docker start my-nginx # Start it again
- The container keeps its data, configuration, and name.
- Any changes made to the container's filesystem persist.
Key Differences
docker runcreates a new container every time you use it.docker startonly works on containers that already exist (but are stopped).- You can only use
docker runwith an image;docker startuses a container name or ID. docker runlets you set options (ports, env vars, volumes) at creation;docker startdoes not.
When to Use Each Command
- Use
docker runwhen you want a fresh container, possibly with new options. - Use
docker startto restart a stopped container with the same settings and data. - For stateless or short-lived containers,
docker runis common. - For persistent services or debugging,
docker startis handy.
Best Practices
- Name your containers with
--namefor easier management. - Use
docker ps -ato see all containers (running and stopped). - Remove containers you no longer need with
docker rmto avoid clutter.
Conclusion
docker run and docker start serve different purposes: one creates and starts new containers, the other restarts existing ones. Use the right command for your workflow to keep your Docker environment organized and efficient.
Related Resources
- How to Run a Docker Image as a Container — running containers in depth
- Docker Image vs Container — understand the fundamentals
- Docker List Containers — find your containers
- Why Docker Container Exits Immediately — troubleshoot exits
- Introduction to Docker Guide — comprehensive learning
- Docker Flashcards — review concepts
We earn commissions when you shop through the links below.
DigitalOcean
Cloud infrastructure for developers
Simple, reliable cloud computing designed for developers
DevDojo
Developer community & tools
Join a community of developers sharing knowledge and tools
Acronis
The most secure backup
Acronis: the most secure backup solution for your data
Pluralsight
Technology skills platform
Expert-led courses in software development, IT ops, data, and cybersecurity
Want to support DevOps Daily and reach thousands of developers?
Become a SponsorFound an issue?