Docker installation on Centos 7/Ubuntu 16.04 in 5 min

Here is to commands to install docker and run with a non-privileged user

Centos 7

sudo su -
 yum install -y yum-utils device-mapper-persistent-data lvm2
 yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
 yum install docker-ce -y
systemctl start docker
systemctl enable docker
usermod -aG docker myuser

Ubuntu 16.04-LTS

sudo su -
 apt-get update
 apt-get install apt-transport-https ca-certificates curl software-properties-common
 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
 add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
 apt-get update
 apt-get install docker-ce
usermod -aG docker myuser

Notes:

  • The Docker daemon starts automatically on Ubuntu. No need to enable it manually on boot
  • Docker socket file is writable by only docker group. We issued usermod command add a user to docker group.
$ ls -al /var/run/docker.sock
srw-rw----. 1 root docker 0 Feb 3 05:33 /var/run/docker.sock

then login with myuser (if you already login, then logout and login again)

run some docker commands to test

$ docker run hello-world

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

ismail yenigul

AWS Certified Cloud Expert

 

Advertisements
Docker installation on Centos 7/Ubuntu 16.04 in 5 min

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s