这里推荐使用云服务器(阿里云、华为云、腾讯云)能够无偿使用几天。在咱们买了服务器后会遇到以下问题:html
咱们须要在管理服务器的界面找到安全组那一栏,而后在安全组出入都要加入icmp这个,建议直接一键添加全部。
而后咱们在本地电脑就能够ping通服务器了。linux
在布置好云服务器后,咱们使用apt-get update, apt-get upgrade
更新信息。
而后,咱们输入docker
,出现以下错误:
接着,咱们按照一般的按照软件的方法apt-get install docker.io, apt-get install docker.ce
,发现出现如下问题nginx
Package 'docker-ce' has no installation candidate
处理办法以下:docker
#添加docker源 sudo echo "deb https://download.docker.com/linux/ubuntu zesty edge" > /etc/apt/sources.list.d/docker.list #支持解析https apt-get install -y apt-transport-https ca-certificates curl software-properties-common #添加GPG密钥 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"
而后咱们再执行就能够获得下面的结果了
接着就是验证安装结果了,输入docker run hello-world
ubuntu
接下来就是安装nginx了,常规操做apt-get install nginx
接下来就是查看安装效果了,输入命令service start nginx
,而后浏览器输入服务器外网ip地址就能够看到nginx默认的界面了。这里会出现一些问题:vim
问题:nginx: [emerg] bind() to [::]:80 failed (98: Address already in use) nginx: [emerg] still could not bind()
解决办法:netstat -ntlp | grep 80
查看
而后输入service nginx stop
,再次查看就没有了浏览器
解决办法安全
vim /etc/nginx/nginx.conf 将添加的 server { .... } 放到 http { ... } 就能够解决了
首先:mkdir -p /var/www/html
而后 cd到目录,接着执行vim index.html
html中的内容本身定义
而后保存退出,而后修改配置文件中默认的index.html路径,以下
服务器
而后重启nginx,service nginx restart
curl
最后,咱们启动docker容器的镜像就能够了,以下
最后就是查看效果了,浏览器输入地址和端口号就能够了