将本周博客作业提交地址:https://www.wjx.top/jq/85988108.aspx
1、通过 RPM 安装 docker 17.03.0 版本并且配置 docker 阿里加速
#docker的源
wget -P /etc/yum.repos.d/ https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
#清理下缓存
yum clean all
yum makecache
#安装
yum -y install docker-ce-17.03.0.ce-1.el7.centos
#配置 docker 阿里加速
vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://hpqoo1ip.mirror.aliyuncs.com"]
}
2、通过 docker 安装一个 LAPM 架构
#pull个镜像
docker pull mattrayner/lamp
#运行该镜像
[ root@centos7-3 ~]# docker run -itd -p 8888:80 -p 6666:3306 -v /var/www:/var/www/html -v /var/mysql:/var/lib/mysql --name=lamp mattrayner/lamp
移动容器内的/var/www/html/wordpress/* 到/var/www/html/*
#托一个wordpress包到宿主机的/var/www并且解压
访问宿主机的IP地址后面跟4个8的端口就行了
3、写出 docker run 命令的延申指令,如怎么在停止一个 docker 容器的时候自动删除该容器
#一次性运行容器,退出后立即删除
root@ubuntu1804:~# docker run -d --rm httpd
31f7c892c53414ca6981dc7c74cbfdd0b0ad745897a84951f051ae5e68b85ae7
root@ubuntu1804:~# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
31f7c892c534 httpd "httpd-foreground" 8 seconds ago Up 6 seconds 80/tcp strange_allen
622dd5eee1b5 httpd "httpd-foreground" About an hour ago Up About an hour 80/tcp interesting_sanderson
a7fbb5296b82 centos "/bin/bash" 23 hours ago Up 23 hours 0.0.0.0:8888->80/tcp mystifying_babbage
c56bc40e5b69 icoty1/lamp:v1.1.0 "/bin/bash" 31 hours ago Up 24 hours 0.0.0.0:8080->80/tcp, 0.0.0.0:3366->3306/tcp stoic_thompson
root@ubuntu1804:~# docker stop 31f7c892c534
31f7c892c534
#已经没有31f7c892c534这个容器了
root@ubuntu1804:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
622dd5eee1b5 httpd "httpd-foreground" About an hour ago Up About an hour 80/tcp interesting_sanderson
a7fbb5296b82 centos "/bin/bash" 23 hours ago Up 23 hours 0.0.0.0:8888->80/tcp mystifying_babbage
c56bc40e5b69 icoty1/lamp:v1.1.0 "/bin/bash" 31 hours ago Up 24 hours 0.0.0.0:8080->80/tcp, 0.0.0.0:3366->3306/tcp stoic_thompson
4、写出 docker run 命令在自动启动 docker 服务时通过什么参数能够启动 docker 中的容器,从而实现容器随着 docker 服务的启动而自动启动
#-d后台运行 --name起个名 -p映射端口
root@ubuntu1804:~#docker run -d --name nginx --restart=always -p 80:80 nginx