1、使用mysql:5.6和 owncloud 镜像,构建一个个人网盘。
[root@node1 ~]# docker pull mysql:5.6
[root@node1 ~]# docker pull owncloud
[root@node1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql 5.6 dd3b2a5dcb48 20 months ago 303MB
owncloud latest 327bd201c5fb 4 years ago 618MB
[root@node1 ~]# [root@node1 ~]# docker run -itd --name mysql --env MYSQL_ROOT_PASSWORD=123456 mysql:5.6
534147e0299de38d65b812a60308d2814b0d825c16e7b627dd331111ae592b78
[root@node1 ~]# docker run -itd --name web --link mysql:mysql -p 80:80 owncloud:latest
f7296c932215ebc76032cf92b2fb6e3bb0865f8ebc42a96b3822efccdd31b071
[root@node1 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f7296c932215 owncloud:latest "docker-entrypoint.s…" About a minute ago Up About a minute 0.0.0.0:80->80/tcp, :::80->80/tcp web
534147e0299d mysql:5.6 "docker-entrypoint.s…" 23 minutes ago Up 23 minutes 3306/tcp mysql
登录
2、安装搭建私有仓库 Harbor
1、安装docker编排工具docker-compose
[root@node1 ~]# curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
[root@node1 ~]# chmod +x /usr/local/bin/docker-compose
[root@node1 ~]# docker-compose version
Docker Compose version v2.20.3
2、下载Harbor安装包
[root@node1 ~]# wget -c https://github.com/goharbor/harbor/releases/download/v2.4.1/harbor-offline-installer-v2.4.1.tgz
[root@node1 ~]# tar xf harbor-offline-installer-v2.8.4.tgz -C /usr/local/
#配置Harbor服务
[root@node1 ~]# cd /usr/local/harbor/
[root@node1 harbor]# cp harbor.yml.tmpl harbor.yml
[root@node1 harbor]# vim harbor.yml
hostname: www.openlab.cn
#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/path 注释
#运行安装脚本
[root@node1 harbor]# ./install.sh
#验证
[root@node1 harbor]# ss -lntup | grep docker
tcp LISTEN 0 128 127.0.0.1:1514 *:* users:(("docker-proxy",pid=2160,fd=4))
tcp LISTEN 0 128 *:80 *:* users:(("docker-proxy",pid=2648,fd=4))
tcp LISTEN 0 128 [::]:80 [::]:* users:(("docker-proxy",pid=2653,fd=4))
[root@node1 harbor]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
82cfabb48518 goharbor/nginx-photon:v2.8.4 "nginx -g 'daemon of…" 33 minutes ago Up 33 minutes (healthy) 0.0.0.0:80->8080/tcp, :::80->8080/tcp nginx
cba8220bdaac goharbor/harbor-jobservice:v2.8.4 "/harbor/entrypoint.…" 33 minutes ago Up 33 minutes (healthy) harbor-jobservice
8fccbcce1df4 goharbor/harbor-core:v2.8.4 "/harbor/entrypoint.…" 33 minutes ago Up 33 minutes (healthy) harbor-core
650e51cce899 goharbor/registry-photon:v2.8.4 "/home/harbor/entryp…" 33 minutes ago Up 33 minutes (healthy) registry
88168c6a76cd goharbor/redis-photon:v2.8.4 "redis-server /etc/r…" 33 minutes ago Up 33 minutes (healthy) redis
3551d289961b goharbor/harbor-db:v2.8.4 "/docker-entrypoint.…" 33 minutes ago Up 33 minutes (healthy) harbor-db
2aef092a46c1 goharbor/harbor-portal:v2.8.4 "nginx -g 'daemon of…" 33 minutes ago Up 33 minutes (healthy) harbor-portal
0f5ea6a25345 goharbor/harbor-registryctl:v2.8.4 "/home/harbor/start.…" 33 minutes ago Up 33 minutes (healthy) registryctl
182670cfb5b6 goharbor/harbor-log:v2.8.4 "/bin/sh -c /usr/loc…" 33 minutes ago Up 33 minutes (healthy) 127.0.0.1:1514->10514/tcp harbor-log
通过IP访问,输入账号admin,密码Harbor12345(初始密码在harbor.yml 文件有记录)
创建用户
创建项目
3、编写Dockerfile制作Web应用系统nginx镜像,生成镜像nginx:v1.1,并推送其到私有仓库。具体要求如下:
(1)基于centos基础镜像;
(2)指定作者信息;
(3)安装nginx服务,将提供的dest目录(提供默认主页index.html)传到镜像内,并将dest目录内的前端文件复制到nginx的工作目录;
(4)暴露80端口;
(5)设置服务自启动。
(6)验证镜像。
[root@node1 ~]# mkdir nginx
[root@node1 ~]# cd nginx/
[root@node1 nginx]# mkdir dest
[root@node1 nginx]# echo "nginx test page" > dest/index.html
[root@node1 nginx]# vim Dockerfile
FROM centos:7
MAINTAINER "WWW"
RUN yum install -y http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.24.0-1.el7.ngx.x86_64.rpm
COPY dest/index.html /usr/share/nginx/html/
EXPOSE 80/tcp
ENTRYPOINT ["nginx", "-g", "daemon off;"]
[root@node1 nginx]# docker build -t nginx:v1.1 ./
[+] Building 107.0s (8/8) FINISHED docker:default
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 270B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/centos:7 24.6s
=> CACHED [1/3] FROM docker.io/library/centos:7@sha256:be65f488b7764ad3638f236b7b515b3678369a5124c47b8d32916d6487418ea4 0.0s
=> [2/3] RUN yum install -y http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.24.0-1.el7.ngx.x86_64.rpm 80.5s
=> [internal] load build context 0.1s
=> => transferring context: 86B 0.0s
=> [3/3] COPY dest/index.html /usr/share/nginx/html/ 0.1s
=> exporting to image 1.7s
=> => exporting layers 1.7s
=> => writing image sha256:b2787336da641bb0832530fe542d5d475db122e5d2211d669b3db935c19ed1f8 0.0s
=> => naming to docker.io/library/nginx:v1.1
[root@node1 nginx]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx v1.1 b2787336da64 About a minute ago 431MB
[root@node1 ~]# vim /etc/hosts
#添加
192.168.40.128 www.openlab.cn
[root@node1 ~]# vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://hnjwpdu9.mirror.aliyuncs.com"],
"insecure-registries": ["www.openlab.cn"]
}
#登录
[root@node1 ~]# docker login www.openlab.cn
Username: admin
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
#推送
[root@node1 ~]# docker tag nginx:v1.1 www.openlab.cn/library/nginx:v1.1
[root@node1 ~]# docker push www.openlab.cn/library/nginx:v1.1
The push refers to repository [www.openlab.cn/library/nginx]
13322b8ab5ee: Pushed
73b21a078cab: Pushed
174f56854903: Pushed
v1.1: digest: sha256:98a7b5b5c3b9dfb30e44d80ff01d7eb7f3d027be6ac195f579ffc9b82d37c472 size: 948
4、Dockerfile快速搭建自己专属的LAMP环境,生成镜像lamp:v1.1,并推送到私有仓库。具体要求如下:
(1)基于centos:7基础镜像;
(2)指定作者信息;
(3)安装httpd、mysql、mysql-server、php、php-mysql、php-gd;
(4)暴露80和3306端口;
(5)设置服务自启动。
(6)验证镜像。文章来源:https://www.toymoban.com/news/detail-669332.html
[root@node1 ~]# mkdir lamp
[root@node1 ~]# cd lamp
[root@node1 lamp]# vim Dockerfile
FROM centos:7
MAINTAINER "z<z@com>"
RUN yum install -y httpd mysql mysql-server php php-mysql php-gd
EXPOSE 80/tcp
EXPOSE 3306/tcp
CMD ["httpd", "-DFOREGROUND"]
[root@node1 lamp]# docker build -t lamp:v1.1 .
[+] Building 69.3s (6/6) FINISHED docker:default
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 200B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/centos:7 6.2s
=> CACHED [1/2] FROM docker.io/library/centos:7@sha256:9d4bcbbb213dfd745b58be38b13b996ebb5ac315fe75711bd618426a630e0987 0.0s
=> => resolve docker.io/library/centos:7@sha256:9d4bcbbb213dfd745b58be38b13b996ebb5ac315fe75711bd618426a630e0987 0.0s
=> [2/2] RUN yum install -y httpd mysql mysql-server php php-mysql php-gd 59.9s
=> exporting to image 3.1s
=> => exporting layers 3.1s
=> => writing image sha256:8c770dc5d236f60179ae1f774d40ff3a2742b96eba78a7e158bb9fc75f80c121 0.0s
=> => naming to docker.io/library/lamp:v1.1 0.0s
[root@node1 lamp]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
lamp v1.1 8c770dc5d236 About a minute ago 569MB
[root@node1 lamp]# docker login www.openlab.cn
[root@node1 lamp]# docker tag lamp:v1.1 www.openlab.cn/lamp/lamp:v1.1
[root@node1 lamp]# docker push www.openlab.cn/lamp/lamp:v1.1
成功
文章来源地址https://www.toymoban.com/news/detail-669332.html
到了这里,关于【使用mysql:5.6和 owncloud 镜像,构建一个个人网盘。 安装搭建私有仓库 Harbor】的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!