Exec into a container as root

Opens a root shell even if the container runs as a non-root user

docker exec -it -u root <container> bash

tool
docker46 commands
tags
dockerdebug

More docker commands

  • docker cp ./local-file.conf <container>:/etc/app/config.conf

    Puts a file into a running container without rebuilding the image

  • docker load < img.tar.gz

    Imports an image saved with docker save

  • docker exec -it registry bin/registry garbage-collect /etc/docker/registry/config.yml

    Frees disk space in a self-hosted Docker Registry

  • docker build --target builder -t img:builder .

    Builds a multi-stage Dockerfile only up to the given stage

  • docker build --build-arg APP_VERSION=1.2.3 --build-arg ENV=prod -t myapp:1.2.3 .

    Passes build-time variables to ARG instructions in the Dockerfile

all 46 docker commands