1、Docker安装脚本
install Docker script: https://gist.github.com/xiaopeng163/f3e72bb1990860859076985d5a723cba
获取到的Docker安装配置 install-docker.sh文件
# install docker
curl -fsSL get.docker.com -o get-docker.sh
sh get-docker.sh
if [ ! $(getent group docker) ];
then
sudo groupadd docker;
else
echo "docker user group already exists"
fi
sudo gpasswd -a $USER docker
newgrp docker #更新docker组
sudo service docker restart
rm -rf get-docker.sh
2、在Ubuntu中安装docker
sh install-docker.sh
docker version
3、启动docker
sudo service docker start
docker version
4、解决/var/run/docker.sock: permission denied
newgrp docker #更新docker组
5、拉取nginx镜像并安装
docker pull nginx
docker image ls
6、设置端口映射
docker run -d -p 80:80 nginx
curl 127.0.0.1:80
在windows 浏览器中打开,也能正常访问。
7、设置docker 开机自动启动
sudo systemctl enable docker