Skip to content

Instantly share code, notes, and snippets.

@leny
Last active March 2, 2020 10:39
Show Gist options
  • Save leny/350456e7417d3e0f1d745e88c27b8268 to your computer and use it in GitHub Desktop.
Save leny/350456e7417d3e0f1d745e88c27b8268 to your computer and use it in GitHub Desktop.

docker

⚠ WARNING: be careful and follow the procedure. Each step is important.


Install docker

For Linux (Ubuntu)

For Ubuntu 19.10 and most recent

  1. Run the following command
  • snap install docker
  • sudo chmod 666 /var/run/docker.sock

For older versions of Ubuntu

👉 The following procedure is taken from this page.

  1. Install docker (run the following commands):
  • sudo apt-get remove docker docker-engine docker.io containerd runc
  • sudo apt-get update
  • sudo apt-get install -yqq apt-transport-https ca-certificates curl gnupg-agent software-properties-common
  • curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
  • sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  • sudo apt-get update
  • sudo apt-get install docker-ce docker-ce-cli containerd.io
  1. Setup your user to be able to run docker without sudo:
  • sudo usermod -aG docker your-user
  1. Install docker-compose:
  • sudo curl -L "https://github.com/docker/compose/releases/download/1.25.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  • sudo chmod +x /usr/local/bin/docker-compose
  1. Restart your computer

For macOS

Follow the procedure on this page

For Windows

Pro, Enterprise or Education versions

Follow the procedure on this page

Home version

To use docker on Windows Home, you need to use the Docker Toolbox, which use VirtualBox to run docker on your machine.

⚠️ Important notes for Windows Home version

The Docker Toolbox and the VirtualBox env will change two important things when you use docker :

  1. The host to access the containers isn't localhost, but the IP 192.168.99.100 (by default)
  2. Due to the nature of VirtualBox, the volumes binding between your local system and the containers are kinda limited. Please ensure that your working folder is inside the C:/Users path.

Testing your installation

Simply run the following command (without sudo): docker run hello-world. The following response should appear after some time:

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment