Docker Installation on ubuntu



1- install docker

2- download an image

3- creating a Dockerfile

New way
sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get install docker -y
sudo apt-get install docker-compose -y
docker --version
docker-compose version
Allow none-root user to run docker:
Create the docker group:  $ sudo groupadd docker
Add your user to the docker group:  $ sudo usermod -aG docker $USER
( also sometime : 
sudo chmod 666 /var/run/docker.sock  ) 
>> Logout and log back in

sudo apt install python3-pip


1a- check the release

me@ubuntu:~$ lsb_release -a    ( or  more /etc/lsb-release  )
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.10
Release:        16.10
Codename:       yakkety

1b- remove all docker installation

#sudo apt-get remove docker docker-engine


1c- update all package + Install important packages

sudo apt-get update

sudo apt-get install \
   apt-transport-https \
   ca-certificates \
   curl \
   software-properties-common

1d- Add Docker’s official GPG key:

curl -fsSL <DOCKER-EE-URL>/gpg | sudo apt-key add -

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
>> the output is just "OK"


Verify that the key fingerprint is DD91 1E99 5A64 A202 E859 07D6 BC14 F10B 6D08 5F96.
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) <docker@docker.com>
sub   4096R/F273FCD8 2017-02-22

1e- set up the stable repository ( Debian or Ubuntu )


sudo add-apt-repository \
  "deb [arch=amd64] https://download.docker.com/linux/debian \
  $(lsb_release -cs) \
  stable"

or

sudo add-apt-repository \
  "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) \
  stable"


1f- update all package + Install docker

sudo apt-get update
apt-get install docker-ce

1g- check the installed docker version


me@ubuntu:~$ apt-cache madison docker-ce
docker-ce | 17.03.0~ce-0~ubuntu-yakkety | https://download.docker.com/linux/ubuntu yakkety/stable amd64 Packages

root@ubuntu:~# apt-cache madison docker-ce
docker-ce | 17.03.0~ce-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages



2a- Basic test: hello-world


me@ubuntu:~$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
78445dd45222: Pull complete
Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
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.
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

2b- More ambitious test:


root@ubuntu:~# docker run -it ubuntu bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
d54efb8db41d: Pull complete
f8b845f45a87: Pull complete
e8db7bf7c39f: Pull complete
9654c40e9079: Pull complete
6d9ef359eaaa: Pull complete
Digest: sha256:dd7808d8792c9841d0b460122f1acf0a2dd1f56404f8d1e56298048885e45535
Status: Downloaded newer image for ubuntu:latest
root@e86ddbf41291:/# ls
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

root@ubuntu:~# docker ps --all
CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS                     PORTS               NAMES
e86ddbf41291        ubuntu              "bash"              About a minute ago   Exited (0) 9 seconds ago                       nervous_tesla
0519ec79d167        hello-world         "/hello"            2 minutes ago        Exited (0) 2 minutes ago                       romantic_bell












Learn Docker in 12 Minutes:

https://www.youtube.com/watch?v=YFl2mCHdv24




Get Docker for Ubuntu

https://docs.docker.com/engine/installation/linux/ubuntu/#install-using-the-repository


https://computingforgeeks.com/how-to-install-docker-on-ubuntu/




Share images, automate workflows, and more with a free Docker ID:

https://cloud.docker.com/


For more examples and ideas, visit:

https://docs.docker.com/engine/userguide/




Kali 2016.1, Docker Install script

https://gist.github.com/apolloclark/f0e3974601346883c731