Dokcer基础
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Dokcer基础相关的知识,希望对你有一定的参考价值。
centos7
yum -y install docker
docker加速
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://224ac393.m.daocloud.io
4.systemctl start docker
[[email protected] ~]# systemctl status docker ● docker.service - Docker Application Container Engine Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled) Active: active (running) since Thu 2016-12-22 20:25:00 CST; 1 weeks 5 days ago Docs: http://docs.docker.com Main PID: 799 (docker-current) Memory: 39.1M CGroup: /system.slice/docker.service ├─ 799 /usr/bin/docker-current daemon --registry-mirror=http://224ac393.m.daocloud.io --exec-opt native.cg... └─28516 docker-proxy -proto tcp -host-ip 59.110.25.215 -host-port 88 -container-ip 192.168.0.2 -container-p..
4.拉公共的镜像
docker pull centos docker pull nginx docker save -o nginx.tar.gz nginx docker save -o centos.tar.gz centos docker load --input nginx.tar.gz docker load --input centos.tar.gz
5.启动一个nginx
docker run -d --name mynginx -p 59.110.25.215:88:80 nginx 说明:基于nginx镜像启动一个mynginx的容器 本机端口 88 端口对应容器 80 端口 浏览: 指定多个端口: docker run -d --name mynginx -p 59.110.25.215:88:80 -p 59.110.25.215:443:443 nginx
6.查看对应的端口
docker port mynginx [[email protected] ~]# docker port mynginx 80/tcp -> 59.110.25.215:88 [[email protected]1 ~]#
7.进入docker容器
#!/bin/bash # Use nsenter to access docker docker_in(){ NAME_ID=$1 PID=$(docker inspect -f "{{ .State.Pid }}" $NAME_ID) nsenter -t$PID -m -u -i -n -p } docker_in $1 上述的脚本就是dockerin.sh [[email protected] ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1f3d2f356995 nginx "nginx -g ‘daemon off" 18 minutes ago Up 18 minutes 443/tcp, 59.110.25.215:88->80/tcp mynginx [[email protected] ~]# bash dockerin.sh 1f3d2f356995 [email protected]:/#
8.进入容器以后修改容器内部的东西
[email protected]:/usr/share/nginx/html# echo "hello everyone" > index.html [email protected]:/usr/share/nginx/html# pwd /usr/share/nginx/html [email protected]:/usr/share/nginx/html#
本文出自 “砖家博客” 博客,请务必保留此出处http://wsxxsl.blog.51cto.com/9085838/1888718
以上是关于Dokcer基础的主要内容,如果未能解决你的问题,请参考以下文章
[vscode]--HTML代码片段(基础版,reactvuejquery)