Skip to main content

Managing Containers

The core commands you use every day to start, stop, inspect, and rebuild your stack.

List running containers

docker ps

To see only the containers from this project:

docker compose ps

Enter a container

Open a shell inside a running container to run commands in it.

  1. List the running containers with docker ps.
  2. Enter the one you want:
    docker compose exec {container-name} bash
    Example, enter the MySQL container:
    docker compose exec mysql bash
    Example, open the MySQL prompt directly:
    docker compose exec mysql mysql -udefault -psecret
  3. Type exit to leave.
tip

add --user=laradock to run as the Laradock user so created files are owned by your host user: docker compose exec --user=laradock workspace bash.

Stop containers

Stop everything:

docker compose stop

Stop a single container:

docker compose stop {container-name}

Delete containers

docker compose down

View logs

NGINX writes its logs to the logs/nginx directory. For any other container, use:

docker compose logs {container-name}

Follow the log live with -f:

docker compose logs -f {container-name}

See the Docker Compose logs options for more.

Build or rebuild containers

After editing any Dockerfile, rebuild for the change to take effect:

docker compose build

Rebuild a single container instead of all of them:

docker compose build {container-name}

Use --no-cache to force a full, clean rebuild:

docker compose build --no-cache {container-name}

Edit a container's Compose config

Everything about a service lives in its folder: its container definition in <service>/compose.yml and its settings in <service>/defaults.env. For plain value changes (ports, versions, credentials), don't edit files at all, just override the variable in your .env. Edit <service>/compose.yml only for structural changes.

Change the MySQL database name (in mysql/compose.yml):

environment:
MYSQL_DATABASE: laradock
...

Map Redis to a different host port (1111), no file editing needed, just add to your .env:

REDIS_PORT=1111

Edit a Docker image

  1. Find the image's Dockerfile, for mysql it's mysql/Dockerfile.
  2. Edit it as you like.
  3. Rebuild the container:
    docker compose build mysql

Add more services

To add a new service (software), create a folder for it containing a compose.yml with your container definition (plus a defaults.env for its settings, if any), then register it in the root docker-compose.yml by adding an include entry like the existing ones. You'll want to be familiar with the Docker Compose file syntax.