02 March 2021

Sometimes docker compose has a lot of services and there is a cool command to go directly to one container for a specific service:

docker-compose exec my-pretty-service bash

If you need to login as a root

docker-compose exec -u 0 my-pretty-service bash

Example:

version: "3.7"
services:
  my-pretty-service:
    image: ubuntu:20.10
    tty: true
    stdin_open: true

  another-my-pretty-service:
    image: ubuntu:20.10
    tty: true
    stdin_open: true

docker-compose --file ./docker-compose.yml up 
docker-compose exec my-pretty-service bash