Ubuntu 18.04安装docker 以及Nginx服务设置

1.安装须要的包
sudo apt install apt-transport-https ca-certificates software-properties-common curlhtml


2.添加 GPG 密钥,并添加 Docker-ce 软件源,这里仍是以中国科技大学的 Docker-ce 源为例
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \
$(lsb_release -cs) stable"linux


3.添加成功后更新软件包缓存
sudo apt updatenginx


4.安装 Docker-ce
sudo apt install docker-cedocker


5.设置开机自启动并启动 Docker-ce(安装成功后默认已设置并启动,可忽略)
sudo systemctl enable docker
sudo systemctl start dockerubuntu


6.测试运行
sudo docker run hello-world缓存

7.添加当前用户到 docker 用户组,能够不用 sudo 运行 docker(可选)
sudo groupadd docker
sudo usermod -aG docker $USERapp

 

Nginxcurl

1.拉取 nginx镜像
sudo docker pull nginx测试


2.运行镜像
sudo docker run -d -p 80:80 nginx
注释
-d means let the application runs in the backgroup which will be not closed even you close the terminalurl

3.访问localhost check is it ok

4.建一个本身的html


sudo docker run -d -p 8088:80 -v $PWD/httpfiles:/usr/share/nginx/html nginx

httpfiles是你的文件目录

再次访问localhost:8088 check

 

linux经常使用语句:
ls:列出目录
touch xxx.html 新建文件
cd..返回上一级


docker经常使用语句:

1.获取镜像docker pull2.查看镜像信息docker images3.列出容器docker ps4.中止docker stop5.启动docker start

相关文章
相关标签/搜索