2. Docker CLI

Contents

    Docker CLI reference

    Docker create / start / run

    Docker create

    docker create <image-name>

    Docker start

    docker start <container-id>

    Options: by default, STDOUT/STDERR/STDIN are not attached to the terminal
    -a, --attach → attach STDOUT/STDERR and forward signals
    -i, --interactive → attach container's STDIN

    Docker run = create + start

    docker run <image-name> [command]

    Options

    Docker exec

    Run a command in a running container.

    docker exec <container-id> <command>

    Options: by default, STDOUT/STDERR/STDIN are not attached to the terminal

    Docker logs

    docker logs <container-id>

    Options

    Docker ps

    docker ps List all of the containers that are currently running.

    Options

    Docker stop / kill

    Note: Ctrl+C = SIGINT

    Docker rm / system prune

    docker system prune the clean all command...
    docker system prune -a

    Docker attach

    docker attach <container-id>
    Attach local standard input, output, and error streams to a running container.
    IMPORTANT : the process with PID 1 is choosen inside the container for attachment. Be careful if there are multiple processes inside the container!

    Docker login

    docker login
    Log into the Docker Hub repository.

    For the scripts

    Docker push

    Push an image to the Docker Hub repository.

    docker push username/image[:tag]

    By default, latest is pushed.
    IMPORTANT: an image with TWO tags needs to be pushed twice, if we want the two tags to be pushed !

    Misc

    Proudly Powered by Zim 0.75.2.

    Template by Etienne Gandrille, based on ZeroFiveEight and using JQuery Toc Plugin.