How to fix Error response from daemon: Container already running in Docker

DockerBEGINNERLOWUpdated Dec 6, 2025· 213 views

The 'Container already running' error occurs when you try to start a Docker container that is already in a running state. Use docker exec to access the running container, or stop it first if you need to restart it.

Quick fix

Fixes Error response from daemon: Container already running

# List running containers
docker ps

# Check specific container status
docker ps --filter "name=mycontainer"

# Get detailed container state
docker inspect --format='{{.State.Status}}' mycontainer
  1. Check the container's current status
  2. Use docker exec to access the running container
  3. Restart the container if needed
  4. Stop the container before starting
docker — error
# List running containers
docker ps
# Check specific container status
docker ps --filter "name=mycontainer"
# Get detailed container state
docker inspect --format='{{.State.Status}}' mycontainer
Error response from daemon: Container already running

What this error means

The "Error response from daemon: Container already running" message appears when you attempt to use `docker start` on a container that is currently in a running state. Docker prevents this action because starting an already-running container doesn't make sense and could indicate a misunderstanding of the container's current state. This error is fundamentally different from the "container name already in use" error. Here, the container exists and is actively running, so Docker correctly refuses to "start" it again. The daemon is telling you that your intended action is already satisfied—the container is running. This commonly happens in scripts or CI/CD pipelines where the same `docker start` command is executed multiple times, or when developers forget that a container is already running in the background.

Typical symptoms

  • docker start command returns 'Container already running' error
  • Automation scripts fail when trying to start a container that's already running
  • CI/CD pipeline fails on container start step during retry logic
  • docker start succeeds on first run but fails on subsequent runs
  • Forgetting a container is running in another terminal session

Common causes

  1. Running docker start on a container that is already in a running state
  2. Automation script attempts to start a container without checking its status first
  3. Previous docker start or docker run command succeeded and container is still running
  4. Container has a restart policy that automatically restarted it
  5. Multiple processes or users attempting to start the same container
  6. Confusion between docker start (for existing containers) and docker run (for new containers)

How to fix "Error response from daemon: Container already running"

1Check the container's current status

First, verify the container's state to confirm it's already running:

bash
# List running containers
docker ps

# Check specific container status
docker ps --filter "name=mycontainer"

# Get detailed container state
docker inspect --format='{{.State.Status}}' mycontainer

If the container shows as "running" or "Up", then the docker start command isn't needed—the container is already active.

2Use docker exec to access the running container

If you need to run commands inside the container, use docker exec instead of trying to start it:

bash
# Run a command in the running container
docker exec mycontainer ls -la

# Open an interactive shell
docker exec -it mycontainer /bin/bash

# Or use sh if bash isn't available
docker exec -it mycontainer /bin/sh

# Run as a specific user
docker exec -u root -it mycontainer /bin/bash

The docker exec command runs a new process inside an already-running container, which is typically what you want.

3Restart the container if needed

If you specifically need to restart the container (stop and start), use the docker restart command:

bash
# Restart the container
docker restart mycontainer

# Restart with a custom timeout (seconds to wait before killing)
docker restart -t 30 mycontainer

# Restart multiple containers
docker restart container1 container2 container3

This is equivalent to running docker stop followed by docker start, but in a single command.

4Stop the container before starting

If you need to stop the container first for some reason, then start it again:

bash
# Stop the container gracefully
docker stop mycontainer

# Stop with a shorter timeout (default is 10 seconds)
docker stop -t 5 mycontainer

# Now you can start it
docker start mycontainer

Note that stopping a container sends SIGTERM to the main process, allowing it to shut down gracefully. After the timeout, Docker sends SIGKILL.

5Add status check to automation scripts

In scripts, check if the container is running before attempting to start:

bash
#!/bin/bash
CONTAINER_NAME="mycontainer"

# Check if container is running
if [ "$(docker ps -q -f name=$CONTAINER_NAME)" ]; then
    echo "Container is already running"
else
    echo "Starting container..."
    docker start $CONTAINER_NAME
fi

Or use a more robust approach that handles any state:

bash
#!/bin/bash
CONTAINER_NAME="mycontainer"

# Get container state
STATE=$(docker inspect --format='{{.State.Status}}' $CONTAINER_NAME 2>/dev/null)

case "$STATE" in
    running)
        echo "Container is already running"
        ;;
    exited|created)
        echo "Starting container..."
        docker start $CONTAINER_NAME
        ;;
    *)
        echo "Container not found or in unexpected state: $STATE"
        ;;
esac
6Ignore the error in scripts when acceptable

If it's acceptable for the container to already be running, you can suppress the error:

bash
# Ignore the error and continue
docker start mycontainer 2>/dev/null || true

# Or check exit code explicitly
docker start mycontainer 2>/dev/null
if [ $? -eq 0 ]; then
    echo "Container started"
else
    echo "Container may already be running or doesn't exist"
fi

For idempotent CI/CD pipelines, this approach ensures the step doesn't fail if the container is already running.

Advanced notes

### Understanding Container States

Docker containers can be in several states:
- created: Container exists but has never been started
- running: Container is currently active
- paused: Container processes are paused
- restarting: Container is in the process of restarting
- exited: Container has stopped
- dead: Container failed to stop properly

The docker start command only works on containers that are not in the "running" state.

### Port Forwarding Behavior

Attempting to start an already-running container can sometimes affect port mappings. As noted in GitHub issue [moby/moby#2405](https://github.com/moby/moby/issues/2405), attempting to start a running container could historically cause forwarded ports to disappear from docker ps output. While this has been addressed, it's another reason to check container state before starting.

### Idempotent Container Management

For truly idempotent container startup in automation:

bash
# Ensure container is running regardless of current state
docker start mycontainer 2>/dev/null || docker run -d --name mycontainer myimage

This pattern attempts to start an existing container, and if that fails (because it doesn't exist), creates a new one.

### Docker Compose Behavior

Docker Compose handles this scenario automatically. Running docker-compose up -d on already-running services does nothing (they keep running). It only starts services that aren't running:

bash
# Start services (only starts those not already running)
docker-compose up -d

# Force recreation of running services
docker-compose up -d --force-recreate

### Restart Policies and This Error

If a container has a restart policy like --restart=always, it may automatically restart after stopping. This can lead to the "already running" error if you try to start it immediately after stopping:

bash
# Container with restart policy
docker run -d --restart=always --name myapp myimage

# Stopping it may trigger automatic restart
docker stop myapp
docker start myapp  # May fail if restart policy already restarted it

To prevent this, remove the container or update the restart policy before stopping.

Frequently asked questions

What does "Error response from daemon: Container already running" mean?
The "Error response from daemon: Container already running" message appears when you attempt to use docker start on a container that is currently in a running state. Docker prevents this action because starting an already-running container doesn't make sense and could indicate a misunderstanding of the container's current state. This error is fundamentally different from the "container name already in use" error.
How do I fix "Error response from daemon: Container already running"?
The 'Container already running' error occurs when you try to start a Docker container that is already in a running state. Use docker exec to access the running container, or stop it first if you need to restart it.
What causes "Error response from daemon: Container already running"?
Running docker start on a container that is already in a running state Automation script attempts to start a container without checking its status first Previous docker start or docker run command succeeded and container is still running
Is the "Error response from daemon: Container already running" error serious?
It is a low-severity error — more of a blocker than a risk. The steps above resolve it.

Official resources & further reading