第九周

 

1、通过 RPM 安装 docker 17.03.0 版本并且配置 docker 阿里加速

#配置yum源
wget -O /etc/yum.repos.d/docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
#下载依赖包
yum -y install https://mirrors.aliyun.com/docker-ce/linux/centos/7/x86_64/stable/Packages/docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm

#安装17.03版本
yum -y install docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm
#开机自启
systemctl enable --now docker

配置docker阿里加速 http://cr.console.aliyun.com 阿里官网查看加速地址

 

 

 

2、通过 docker 安装一个 LAPM 架构

在 centos 7 镜像并映射端口启动容器

[root@centos7_10 ~]$ docker pull centos:7     [root@centos7_10 ~]$ docker container run -it --name lamp -p 192.168.1.10:80:80 centos:7

安装 lamp 架构

yum install -y httpd mariadb-server php php-mysql httpd 

启动 httpd

systemctl enable --now  mairadb-server php php-mysql httpd

配置 mariadb

mysql_install_db --defaults-file=/etc/my.cnf --user=mysql --datadir=/var/lib/mysql/

启动 mariadb

mysqld_safe --defaults-file=/etc/my.cnf > mysqld.log 2>&1 &

制作镜像

[root@centos7_10 ~]$ docker commit 22e61d18e7ff lamp:image1

查看端口

[root@49953241b5f5 /]# netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN    
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN    
tcp        0      0 136.0.0.3:49206         117.78.24.34:443       TIME_WAIT  

3、写出 docker run 命令的延申指令,如怎么在停止一个 docker 容器的时候自动删除该容器

docker container run -it --name test --rm centos:7

4、写出 docker run 命令在自动启动 docker 服务时通过什么参数能够启动 docker 中的容器,从而实现容器随着 docker 服务的启动而自动启动

#设置容器总是运行 
[root@ubuntu1804 ~]#docker run -d --name nginx --restart=always -p 80:80 nginx



posted @ 2020-11-15 21:57  肖豪  阅读(89)  评论(0编辑  收藏  举报