get inside a docker container

Open a shell in a running container, copy files in and out, read its logs, share a folder with it.

  • containers

Steps

  1. docker ps

    the running containers and their names

  2. docker exec -it NAME sh

    a shell inside it (bash, if the image has it)

  3. docker logs -f NAME

    its output, as it comes

  4. docker cp NAME:/path/file ./

    copy a file out of it

  5. docker run -it --rm -v "$PWD":/work -w /work ubuntu bash

    a new container with this folder inside it

  6. docker compose exec SERVICE sh

    with Compose, by service name

Commands used

  • docker

Each has a page in lore: lore docker opens it.