[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
d45cc5b95f00692881baafcb9f9b47a0696f5e3a77d0efe95c51faec514ccdc0
[root@localhost ~]# docker run -itd -p 80:80 --name owncloud --link mysql:mysql owncloud
0974b4918aa18c963385297908c606813ad1d1f264f6c7f2333e7305aae4c816
在网页中输入本机的IP地址
#安装docker编排工具docker-compose
[root@localhost ~]# mkdir /harbor
[root@localhost ~]# cd /harbor/
[root@localhost harbor]# curl -L "https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
100 15.4M 100 15.4M 0 0 185k 0 0:01:24 0:01:24 --:--:-- 2270k
#下载Harbor安装包
wget -c https://github.com/goharbor/harbor/releases/download/v2.4.1/harbor-offline-installer-v2.8.4.tgz
#对二进制文件应用可执行权限:
[root@localhost harbor]# chmod +x /usr/local/bin/docker-compose
#测试是否安装成功
[root@localhost harbor]# docker-compose version
docker-compose version 1.24.1, build 4667896b
docker-py version: 3.7.3
CPython version: 3.6.8
OpenSSL version: OpenSSL 1.1.0j 20 Nov 2018
#配置Harbor服务
[root@localhost ~]# tar xf harbor-offline-installer-v2.8.4.tgz -C /usr/local/
[root@node ~]# cd /usr/local/harbor/
[root@node harbor]# ll
total 597560
drwxr-xr-x. 3 root root 20 Aug 25 08:59 common
-rw-r--r--. 1 root root 3639 Aug 15 17:53 common.sh
-rw-r--r--. 1 root root 5836 Aug 25 08:59 docker-compose.yml
-rw-r--r--. 1 root root 611834153 Aug 15 17:54 harbor.v2.8.4.tar.gz
-rw-r--r--. 1 root root 12507 Aug 25 08:57 harbor.yml
-rw-r--r--. 1 root root 12499 Aug 15 17:53 harbor.yml.tmpl
-rwxr-xr-x. 1 root root 2725 Aug 15 17:53 install.sh
-rw-r--r--. 1 root root 11347 Aug 15 17:53 LICENSE
-rwxr-xr-x. 1 root root 1881 Aug 15 17:53 prepare
[root@localhost harbor]# cp harbor.yml.tmpl harbor.yml
[root@localhost harbor]# vim harbor.yml
#添加本地DNS解析
[root@localhost harbor]*# vim /etc/hosts*
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.226.150 node.shenqilun.com
#运行安装脚本
[root@localhost harbor]# ./install.sh
#验证
[root@localhost harbor]# ss -nutlp | grep docker
tcp LISTEN 0 128 127.0.0.1:1514 *:* users:((docker-proxy",pid=2962,fd=4))
tcp LISTEN 0 128 *:8080 *:* users:(("docker-proxy",pid=3476,fd=4))
tcp LISTEN 0 128 *:80 *:* users:(("docker-proxy",pid=2435,fd=4))
tcp LISTEN 0 128 [::]:8080 [::]:* users:(("docker-proxy",pid=3481,fd=4))
tcp LISTEN 0 128 [::]:80 [::]:* users:(("docker-proxy",pid=2441,fd=4))
[root@localhost harbor]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
dfc3d8988784 goharbor/harbor-jobservice:v2.8.4 "/harbor/entrypoint.…" 24 seconds ago Up 18 seconds (health: starting) harbor-jobservice
87cd82a580d4 goharbor/nginx-photon:v2.8.4 "nginx -g 'daemon of…" 24 seconds ago Up 21 seconds (health: starting) 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp nginx
bfbafba66778 goharbor/harbor-core:v2.8.4 "/harbor/entrypoint.…" 24 seconds ago Up 22 seconds (health: starting) harbor-core
77adcfc5f556 goharbor/redis-photon:v2.8.4 "redis-server /etc/r…" 24 seconds ago Up 22 seconds (health: starting) redis
84163d4f70e7 goharbor/registry-photon:v2.8.4 "/home/harbor/entryp…" 24 seconds ago Up 23 seconds (health: starting) registry
eda3f53becbc goharbor/harbor-registryctl:v2.8.4 "/home/harbor/start.…" 24 seconds ago Up 22 seconds (health: starting) registryctl
2b58a4509b1d goharbor/harbor-portal:v2.8.4 "nginx -g 'daemon of…" 24 seconds ago Up 23 seconds (health: starting) harbor-portal
1d3ed7c4465f goharbor/harbor-db:v2.8.4 "/docker-entrypoint.…" 24 seconds ago Up 23 seconds (health: starting) harbor-db
6429fc8e530a goharbor/harbor-log:v2.8.4 "/bin/sh -c /usr/loc…" 24 seconds ago Up 24 seconds (health: starting) 127.0.0.1:1514->10514/tcp harbor-log
86e0be6129a4 owncloud "docker-entrypoint.s…" 10 minutes ago Up 10 minutes 0.0.0.0:80->80/tcp, :::80->80/tcp owncloud
5d7eb2a1b187 mysql:5.6 "docker-entrypoint.s…" 11 minutes ago Up 11 minutes 3306/tcp mysql
[root@localhost harbor]# docker login -u admin -p Harbor12345 1
在网页中输入本机的IP地址加上:8080,用户名admin密码Harbor12345。登录成功页面如下:
(1)基于centos基础镜像;
[root@localhost ~]# docker pull centos:7
(2)指定作者信息;
(3)安装nginx服务,将提供的dest目录(提供默认主页index.html)传到镜像内,并将dest目录内的前端文件复制到nginx的工作目录;
(4)暴露80端口;
(5)设置服务自启动。
[root@localhost ~]# mkdir centos
[root@localhost ~]# cd centos/
[root@localhost centos]# touch index.html
[root@localhost centos]# echo 'Welcon to Nginx' > index.html
[root@localhost centos]# vim Dockerfile
FROM centos:7
MAINTAINER "lsq "
RUN yum install wget -y && cd /etc/yum.repos.d/ && rm -rf ./* && \
wget -0 /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo && \
wget -0 /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;"]
(6)验证镜像。
[root@localhost centos]# docker build -t nginx:v1 .
[root@localhost centos]# docker run -p 8090:80 --name ng nginx:v1
要求如下:
(1)基于centos:6基础镜像;
[root@localhost ~]# mkdir lamp
[root@localhost lamp]#docker pull centos:6
(2)指定作者信息;
(3)安装httpd、mysql、mysql-server、php、php-mysql、php-gd;
(4)暴露80和3306端口;
(5)设置服务自启动。
[root@bogon lamp]#wget -O /root/lamp/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
[root@localhost lamp]# vim Dockerfile
FROM centos:6
MAINTAINER "longsiqi "
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 .
(6)验证镜像。
[root@localhost lamp]# docker run -p 8060:80 --name lp lamp:v1.1