在CentOS 7 和ubuntu 16.04 下安装Docker

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在CentOS 7 和ubuntu 16.04 下安装Docker相关的知识,希望对你有一定的参考价值。

----------CentOS 7---------------------


sudo adduser --system --no-create-home --user-group -s /sbin/nologin docker

sudo yum -y update
sudo cat >> /etc/yum.repos.d/docker.repo <<-‘EOF‘
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF
 
sudo yum install -y docker-engine
sudo yum -y install python-setuptools
sudo easy_install pip
sudo pip install docker-compose
 
do this step if ‘/data‘ is the big storage than ‘/‘
sudo systemctl stop docker.service
sudo mkdir -p /data/docker-var/docker
sudo rm -rf /var/lib/docker
sudo ln -s /data/docker-var/docker /var/lib/docker
 
sudo sed -i ‘s:ExecStart=/usr/bin/docker daemon -H fd\://:ExecStart=/usr/bin/docker daemon -H fd\:// --log-opt max-size=100m --log-opt max-file=50:g‘  /lib/systemd/system/docker.service
sudo systemctl daemon-reload
sudo systemctl restart docker.service


-------------Ubuntu 16.04---------------------

https://docs.docker.com/engine/installation/linux/ubuntulinux/
 
#sudo apt-get update
#sudo apt-get install apt-transport-https ca-certificates
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo ‘deb https://apt.dockerproject.org/repo ubuntu-xenial main‘>/etc/apt/sources.list.d/docker.list
sudo apt-get update
#sudo apt-get purge lxc-docker
apt-cache policy docker-engine
#sudo apt-get install linux-image-extra-$(uname -r)
 
sudo apt-get update
sudo apt-get install docker-engine
sudo service docker start
 
sudo groupadd docker
sudo usermod -aG docker ubuntu
 
sudo apt-get install python-pip
sudo pip install docker-compose
sudo ufw status
sudo nano /etc/default/ufw
"DEFAULT_FORWARD_POLICY="ACCEPT""
sudo ufw allow 2375/tcp
sudo ufw reload


本文出自 “网事” 博客,请务必保留此出处http://gxjluck.blog.51cto.com/1211751/1844337

以上是关于在CentOS 7 和ubuntu 16.04 下安装Docker的主要内容,如果未能解决你的问题,请参考以下文章

Ubuntu16.04和Centos7.5安装Rsync并测试同步文件

Windows 7下安装Ubuntu16.04的方法

Ubuntu16.04和Centos7 Yum部署zabbix3.4 结合钉钉智能报警

win7 下安装 Ubuntu16.04以及Centos6.5 双系统小结

Ubuntu16.04下搭建python3.5+PyQt5.7+Eric6开发环境

在 ubuntu 16.04 server 下安装cacti