1、使用mysql:5.6和 owncloud 镜像,构建一个个人网盘。
创建一个数据库容器:
[root@localhost ~]# docker run -itd --name db --env MYSQL_ROOT_PASSWORD=123456 mysql:5.6
31572df44a7a1a76f31e4faecd68de6373ecc31d98f2d102ce6b84ef395755b0
创建一个owncloud容器并将它连接到db容器:
[root@localhost ~]# docker run --name bbs -d -p 80:80 --link db:db owncloud
14913d5e1a86ec9bf4eee58f8c86701948d9b9b4f5723e23a3181a92b9d85368
此时owncolud
容器已经和
db
容器建立互联关系:
--link
参数的格式为:
--link name:alias
,其中
name
是要连接的容器名称,alias
是这个连接的别名。
Docker
相当于在两个互联的容器之间创建了一个虚拟通道,而不用映射它们的端口到宿主机上。在启动 db容器的时候并没有使用
-p
或者
-P
参数,从而避免了暴露数据库服务端口到外部网络上。
2、安装搭建私有仓库 Harbor
硬件条件:
添加一块50G的大硬盘:
对磁盘进行分区:
[root@localhost harbor]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xea06dd5b.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-104857599, default 2048):
Using default value 2048
L