目录
1、使用mysql:5.6和 owncloud 镜像,构建一个个人网盘。
(1)下载mysql:5.6和owncloud镜像
(2)创建启动mysql:5.6和owncloud容器
(3)在浏览器中输入网盘服务器的IP地址,进行账号注册
2、安装搭建私有仓库 Harbor
(1)下载Harbor安装包并解压,修改配置文件
(2)在浏览器输入hostname和指定的端口号
3、编写Dockerfile制作Web应用系统nginx镜像,生成镜像nginx:v1,并推送其到私有仓库。具体要求如下:
(1)基于centos基础镜像;
(2)指定作者信息;
(3)安装nginx服务,将提供的dest目录(提供默认主页index.html)传到镜像内,并将dest目录内的前端文件复制到nginx的工作目录;
(4)暴露80端口;
(5)设置服务自启动。
(6)验证镜像。
4、Dockerfile快速搭建自己专属的LAMP环境,生成镜像lamp:v1.1,并推送到私有仓库。具体要求如下:
(1)基于centos:6基础镜像;
(2)指定作者信息;
(3)安装httpd、mysql、mysql-server、php、php-mysql、php-gd;
(4)暴露80和3306端口;
(5)设置服务自启动。
(6)验证镜像。
[root@localhost ~]# docker pull mysql:5.6
[root@localhost ~]# docker pull owncloud
[root@localhost ~]# docker run -itd --name mysql --env MYSQL_ROOT_PASSWORD=123456 mysql:5.6
[root@localhost ~]# docker run -itd -p 80:80 --name owncloud --link mysql:mysql owncloud
[root@localhost ~]# tar xf harbor-offline-installer-v2.5.3.tgz
[root@localhost ~]# cd harbor/
[root@localhost harbor]# cp harbor.yml.tmpl harbor.yml
[root@localhost harbor]# vim harbor.yml
编辑内容如下图所示
[root@localhost harbor]# ./install.sh
PS:docker和docker-compose要事先安装好哦!
下载docker-compose插件
curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
赋予该插件执行权限
chmod +x /usr/local/bin/docker-compose
默认账号为admin、密码为Harbor12345
拉取centos镜像
[root@localhost ~]# docker pull centos:7
[root@localhost ~]# mkdir /centos
[root@localhost ~]# cd /centos
[root@localhost centos]# touch index.html
[root@localhost centos]# echo 'hello nginx' > index.html
[root@localhost centos]# vim Dockerfile
FROM centos:7
MAINTAINER "haha "
RUN yum install wget -y && cd /etc/yum.repos.d/ && rm -rf ./* && \
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo && \
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
RUN yum install -y nginx
COPY index.html /usr/share/nginx/html/
EXPOSE 80
CMD ["/usr/sbin/nginx","-g","daemon off;"]
[root@localhost centos]# docker build -t nginx:v1 .
[root@localhost centos]# docker run -p 8080:80 --name ng nginx:v1
[root@localhost ~]# mkdir lamp
[root@localhost ~]# cd lamp/
[root@localhost lamp]# docker pull centos:6
[root@localhost lamp]# vim Dockerfile
FROM centos:6
MAINTAINER "lan "
PS:CentOS 6软件源已经被官方移除
[root@localhost lamp]# wget -O /root/lamp/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
ADD CentOS-Base.repo /etc/yum.repos.d/
RUN yum install -y httpd mysql mysql-server php php-mysql php-gd && \
yum clean all && yum makecache
EXPOSE 80
EXPOSE 3306
CMD ["sh", "-c", "service httpd start && service mysqld start && tail -f /var/log/httpd/access_log"]
[root@localhost lamp]# docker build -t lamp:v1.1 .
[root@localhost lamp]# docker run -p 8070:80 --name lp lamp:v1.1