Installing Docker - cogeorg/teaching GitHub Wiki
Docker containerizes software, i.e. it wraps it and its dependencies in an isolated environment, making it independent from the host system. Thus, you can run it on any device, whether it is a Windows, a Mac or a Linux based system. It is the dream of every DevOps developer.
Installing Docker on Ubuntu
(If you prefer a different linux distribution, you can find installation guides for all of them here.)
-
Update the apt package index:
$ sudo apt-get update
-
Install packages to allow apt to use a repository over HTTPS:
$ sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common
-
Add Docker’s official GPG key:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
-
Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88, by searching for the last 8 characters of the fingerprint.
$ sudo apt-key fingerprint 0EBFCD88 pub 4096R/0EBFCD88 2017-02-22 Key fingerprint = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 uid Docker Release (CE deb) <[email protected]> sub 4096R/F273FCD8 2017-02-22
-
Set up the repository:
$ sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable"
-
Update the apt package index:
$ sudo apt-get update
-
Install the latest version of Docker CE:
$ sudo apt-get install docker-ce
-
Create the docker group.
$ sudo groupadd docker
-
Add your user to the docker group.
$ sudo usermod -aG docker $USER
-
Log out and back in.
-
Run the test:
$ docker run hello-world
You should see the following:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535
Status: Downloaded newer image for hello-world:latest
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/
Installing Docker on MacOS
A detailed installation guide with pictures can be found here. You will have to create an account on dockerhub in order to download the docker software.