Skip to content

Latest commit

 

History

History
77 lines (48 loc) · 1.08 KB

Docker.md

File metadata and controls

77 lines (48 loc) · 1.08 KB

Docker Tutorial

19, Jan. 2019. Jerry ZJ

Installation

  • Mac: Install via homebrew

    $ brew install docker
  • Linux: Install via apt

    $ sudo apt update && sudo apt install docker-io

Post installation

Run docker without sudo

  1. Create the docker user group

    $ sudo groupadd docker
  2. Add current user to the docker group

    $ sudo usermod -aG docker $USER
  3. Log out and log back in so that your group membership is re-evaluated.

Start docker on boot

$ sudo systemctl enable docker

Create a ubuntu docker container with bash

docker run -it --name $Name_of_the_container ubuntu /bin/bash

Leave docker

  • Leave and stop the container

    $ exit
  • Leave without stopping the container

    Ctrl + P & Ctrl + Q
    

Restart container

  • Restart an exited container

    docker start #CONTAINER_ID
  • Attach to the container

    docker attach #CONTAINER_ID