您当前的位置: 首页 >  docker

Peter_Gao_

暂无认证

  • 6浏览

    0关注

    621博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

ubuntu + docker + nginx + 静态html

Peter_Gao_ 发布时间:2020-04-10 10:32:46 ,浏览量:6

安装docker

curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -sudo apt-get update sudo apt install software-properties-common

sudo add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable" sudo apt-get install -y docker-ce

sudo systemctl enable docker

sudo systemctl start docker

sudo docker run hello-world

 

创建用户

sudo usermod -aG docker ${USER} su - ${USER}

sudo groupadd docker

 sudo usermod -aG docker kirk docker volume create portainer_data

docker --version

 docker info

 

安装docker第三方图形管理界面portainer

docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer

docker images

 docker rmi flask-test:latest 

docker system prune -a

docker ps -a

 docker rm suspicious_maxwell 

sudo docker run -d -p 8000:80 flask-test:latest

[10:21:46]kirk@ft_master:/projects/FlaskTest$ ls [10:21:46]app.py  Dockerfile  gun.conf [10:21:54]kirk@ft_master:/projects/FlaskTest$ vi Dockerfile [10:21:54]FROM python:3 [10:21:54]MAINTAINER "username" [10:21:54]ENV PIPURL "https://pypi.tuna.tsinghua.edu.cn/simple" [10:21:54]WORKDIR /projects [10:21:54] [10:21:54]COPY app.py app.py [10:21:54]RUN pip --no-cache-dir install  -i ${PIPURL} --upgrade pip [10:21:54]RUN pip --no-cache-dir install  -i ${PIPURL} gunicorn==19.9.0 [10:21:54]RUN pip --no-cache-dir install  -i ${PIPURL} flask==1.0.2 [10:21:54]RUN pip --no-cache-dir install  -i ${PIPURL} gevent==1.4.0 [10:21:54] [10:21:54]CMD gunicorn  -c gun.conf app:app

 

安装nginx的docker容器

docker search nginx

 docker pull nginx

sudo docker run -d -p 80:80 nginx

 

创建存储目录 

[18:40:18]kirk@ft_master:/projects/dnd4$ ls [18:40:26]kirk@ft_master:/projects/dnd4$ sudo mkdir html [18:40:33]kirk@ft_master:/projects/dnd4$ sudo mkdir conf [18:40:37]kirk@ft_master:/projects/dnd4$ sudo mkdir logs [18:40:39]kirk@ft_master:/projects/dnd4$ ls [18:40:39]conf  html  logs [18:45:42]kirk@ft_master:/projects/dnd4$ cd conf/

 

配置 nginx [18:48:09]kirk@ft_master:/projects/dnd4/conf$ vim nginx.conf

 

同步站点网页文件

]kirk@ft_master:/projects/dnd4/html$ sudo git clone https://gitee.com/PeterGao/dndwebsite.git [18:56:31]Cloning into 'dndwebsite'...  

启动容器并关联与物理机目录位置

kirk@ft_master:/projects/dnd4$ docker run -d -p 80:80 --name dndnginx

-v /projects/dnd4/html:/usr/share/nginx/html

-v /projects/dnd4/conf/nginx.conf:/etc/nginx/nginx.conf

-v /projects/dnd4/logs:/var/log/nginx nginx  

 docker restart dndnginx 

 

修改并同步文件 [14:21:49]kirk@ft_master:/projects/dnd4/html/dndwebsite$ sudo git add . [14:22:49]kirk@ft_master:/projects/dnd4/html/dndwebsite$ sudo git commit -am "up" [14:22:49] [14:22:49]*** Please tell me who you are. [14:22:49] [14:22:49]Run [14:22:49] [14:22:49]  git config --global user.email "you@example.com" [14:22:49]  git config --global user.name "Your Name"

 

 

 

 

关注
打赏
1664521772
查看更多评论
立即登录/注册

微信扫码登录

0.1912s