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
SMTPfast
Developer-first email API
Send transactional and marketing email through a clean REST API. Detailed logs, webhooks, and embeddable signup forms in one dashboard.
QuizAPI
Developer-first quiz platform
Build, generate, and embed quizzes with a powerful REST API. AI-powered question generation and live multiplayer.
Want to support DevOps Daily and reach thousands of developers?
Become a SponsorFound an issue?
Related Posts
Also worth your time on this topic
5 Advanced Docker Features Worth Knowing
Go beyond Docker basics with BuildKit, multi-stage builds, health checks, init processes, and build secrets. Learn practical techniques that improve security, performance, and reliability.
Docker Security Hardening Checklist
Comprehensive security checklist for hardening Docker containers, images, and runtime environments.
60-90 minutes
Running Docker Containers on Your Linux Server
Install Docker and Docker Compose on Ubuntu, run your first container, deploy a WordPress stack with docker-compose, and set up Nginx as a reverse proxy in front of your containers.
60 minutes