Docker 安装
docker安装
Ubuntu系统(脚本安装)
v2admin@ubuntu:~$sudo wget -qO- https://get.docker.com | sh
v2admin@ubuntu:~$sudo usermod -aG docker v2admin // 如果使用非root用户,需要赋予下权限,然后重新登录
启动Docker
v2admin@ubuntu:~$ sudo service docker start
镜像加速
v2admin@ubuntu:~$ sudo vim /etc/docker/daemon.json
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}
启动httpd容器
v2admin@ubuntu:~$ sudo docker run -d -p 80:80 httpd
Unable to find image 'httpd:latest' locally
latest: Pulling from library/httpd
fc7181108d40: Pull complete
b183a5e3b6da: Pull complete
c52952f0d826: Pull complete
c8f255a56e9a: Pull complete
144c3b858b48: Pull complete
Digest: sha256:a129c3a747fe9e406bf91d4d1fb2d4ed7b51d7a1f523fcf372c18c3c35981d12
Status: Downloaded newer image for httpd:latest
533c723b96c6ee52836e9e7a709abba09a46ab93c1a15dd798da920169a482fe
//大致过程,本地没有找到httpd的镜像,然后下载httpd image,image中已经安装好了apache服务。
//启动httpd服务,将容器的80端口映射到host的80端口
v2admin@ubuntu:~$ docker images //查看镜像
REPOSITORY TAG IMAGE ID CREATED SIZE
httpd latest e77c77f17b46 2 weeks ago 140MB
hello-world latest fce289e99eb9 5 months ago
v2admin@ubuntu:~$ docker container ls //查看运行的容器
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c5e83f95908a httpd "httpd-foreground" About a minute ago Up About a minute 0.0.0.0:80->80/tcp sleepy_hawking
v2admin@ubuntu:~$ docker ps //查看运行的容器
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c5e83f95908a httpd "httpd-foreground" About a minute ago Up About a minute 0.0.0.0:80->80/tcp sleepy_hawking