伊利集团的网站建设水平评价,上海设计装修公司排名,wordpress产品发布插件,wordpress代码高亮知乎一、实验要求
1、使用mysql:5.6和 owncloud 镜像#xff0c;构建一个个人网盘。 2、安装搭建私有仓库 Harbor 3、编写Dockerfile制作Web应用系统nginx镜像#xff0c;生成镜像nginx:v1.1#xff0c;并推送其到私有仓库。具体要求如下#xff1a; #xff08;1#xff09…一、实验要求
1、使用mysql:5.6和 owncloud 镜像构建一个个人网盘。 2、安装搭建私有仓库 Harbor 3、编写Dockerfile制作Web应用系统nginx镜像生成镜像nginx:v1.1并推送其到私有仓库。具体要求如下 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验证镜像。 二、实验步骤
1.使用mysql:5.6和 owncloud 镜像构建一个个人网盘
[rootlocalhost ~]# systemctl stop firewalld
[rootlocalhost ~]# setenforce 0
[rootlocalhost ~]# docker pull mysql:5.6
[rootlocalhost ~]# docker pull owncloud
[rootlocalhost ~]# docker run -d --name db --env MYSQL_ROOT_PASSWORD123456 mysql:5.6
[rootlocalhost ~]# docker run -d --name owncloud -p 80:80 --link db:db owncloud
1.1 在浏览器中输入网盘服务器的IP地址进行账号注册 1.2 注册完成登录账号 1.3 登录成功并上传测试文件 1.4 查看上传成功的文件 2.安装搭建私有仓库 Harbor
2.1 上传Harbor离线安装包
[rootlocalhost ~]# ll
[rootlocalhost ~]# tar xf harbor-offline-installer-v2.4.1.tgz
[rootlocalhost ~]# ls
[rootlocalhost ~]# cd harbor/
[rootlocalhost ~]# cp harbor.yml.tmpl harbor.yml2.2 修改配置文件
[rootlocalhost harbor]# vim harbor.yml
//这里改动三个地方:hostname、port、注释https的内容
hostname: harbor.openlab.cn
http:port: 80
#https:#https port for harbor, default is 443#port: 443#The path of cert and key files for nginx#certificate: /your/certificate/path#private_key: /your/private/key/path2.3 安装Harbor
[rootlocalhost harbor]# ./install.sh
[] Running 10/10✔ Network harbor_harbor Created 0.0s ✔ Container harbor-log Started 0.3s ✔ Container redis Started 0.9s ✔ Container harbor-portal Started 0.5s ✔ Container registry Started 0.8s ✔ Container harbor-db Started 1.0s ✔ Container registryctl Started 0.9s ✔ Container harbor-core Started 1.1s ✔ Container harbor-jobservice Started 1.5s ✔ Container nginx Started 1.6s
✔ ----Harbor has been installed and started successfully.----
安装完成之后再浏览器中访问默认账号为admin、密码为Harbor12345
2.3 在浏览器中访问Harbor 2.4 登录成功创建用户tom 2.5 新建test项目且添加用户tom 2.6 修改daemon.json配置文件
[rootlocalhost harbor]# vim /etc/docker/daemon.json
{registry-mirrors:[https://registry.docker-cn.com],insecure-registries:[192.168.64.3],insecure-registries:[harbor.openlab.cn]
}2.7 修改hosts配置文件
[rootlocalhost harbor]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.64.3 harbor.openlab.cn2.8 更改本地主机名
[rootlocalhost harbor]# hostnamectl set-hostname harbor.openlab.cn2.9 重启服务登录
[rootlocalhost harbor]# systemctl restart docker
[rootlocalhost harbor]# docker-compose up -d
[] Running 9/7✔ Container harbor-log Running 0.0s ✔ Container harbor-portal Started 0.0s ✔ Container registryctl Running 0.0s ✔ Container harbor-db Running 0.0s ✔ Container registry Started 0.0s ✔ Container redis Started 0.0s ✔ Container harbor-core Started 0.0s ✔ Container nginx Started 0.0s ✔ Container harbor-jobservice Started 0.0s[rootlocalhost harbor]# docker login -u tom -p Harbor12345 192.168.64.3
注意如果在输入第二条命令docker-compose up -d报错-bash: docker-compose: command not found则可以参考以下解决方案
1.从官网下载docker-compose插件
curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose2.赋予该插件执行权限
chmod x /usr/local/bin/docker-compose3.查看docker-compose版本信息
docker-compose --version 3.编写Dockerfile制作Web应用系统nginx镜像生成镜像nginx:v1.1并推送其到私有仓库
3.1 Dockerfile内容如下
FROM centos:7
MAINTAINER yuchen yuchendomain.com
COPY epel.repo /etc/yum.repos.d
RUN yum install -y nginx
COPY index.html /usr/share/nginx/html/EXPOSE 80
CMD [/usr/sbin/nginx,-g,daemon off;]3.2 制作镜像nginx:v1.1
[rootharbor nginx]# docker build -t nginx:v1.1 ./3.3 验证镜像
[rootlocalhost nginx]# docker run -p 8080:80 --name ng111 nginx:v1.1
[rootlocalhost nginx]# docker ps | grep ng111
a95b39e9e7ce nginx:v1.1 /usr/sbin/nginx -g … 8 minutes ago Up 8 minutes 0.0.0.0:8080-80/tcp, :::8080-80/tcp ng1113.4 上传镜像至Harbor
[rootlocalhost ~]# docker tag nginx:v1.1 node1.openlab.cn/test/nginx:v1.1
[rootlocalhost ~]# docker push node1.openlab.cn/test/nginx:v1.1 4.Dockerfile快速搭建自己专属的LAMP环境生成镜像lamp:v1.1并推送到私有仓库
4.1 Dockerfile文件如下
FROM centos:7
MAINTAINER 1711582538 1711582538qq.com
RUN yum install -y httpd mariadb-server php php-mysql php-gd
RUN echo welcome to my pages /var/www/html/index.html
EXPOSE 80
EXPOSE 3306
CMD [httpd,-DFOREGOUND;]4.2 验证镜像
FROM centos:7
MAINTAINER 1711582538 1711582538qq.com
RUN yum install -y httpd mariadb-server php php-mysql php-gdRUN mkdir -p /scripts
COPY dd.sh /scripts
WORKDIR /scripts
RUN chmod x dd.sh
RUN ./dd.sh
EXPOSE 80
EXPOSE 3306#!/bin/bashchown -R mysql:mysql /var/lib/mysql
mysql_install_db --usermysql /dev/nullmysql_sage --usermysql
/usr/sbin/httpd -D FOREGROUND4.3 编辑文件
[rootharbor lamp]# docker build -t lamp:v1.1 ./
[rootlharbor lamp]# docker run -it -p 88:80 lamp:v1.1
[rootlharbor lamp]# cd /var/www/html/
[rootharbor lamp]# vim index.php?php
phpinfo();
?4.4 上传镜像
[rootharbor ~]# docker tag lamp:v1.1 node1.openlab.cn/test/lamp:v1.1
[rootharbor ~]# docker push node1.openlab.cn/test/lamp:v1.1