[root@localhost ~]# docker run -it --name docker01 yyds/centos
[root@a37f3d845ace /]# ls
bin home lost+found opt run sys var
dev lib media proc sbin tmp volume01
etc lib64 mnt root srv usr volume02
[root@a37f3d845ace /]# ls
bin home lost+found opt run sys var
dev lib media proc sbin tmp volume01
etc lib64 mnt root srv usr volume02
[root@a37f3d845ace /]# cd volume01
[root@a37f3d845ace volume01]# ls
111
[root@a37f3d845ace volume01]#
[root@localhost ~]# docker run -it --name docker02 --volumes-from docker01 yyds/centos
[root@642745708b59 /]# ls
bin home lost+found opt run sys var
dev lib media proc sbin tmp volume01
etc lib64 mnt root srv usr volume02
[root@642745708b59 /]# cd volume01
[root@642745708b59 volume01]# ls
[root@642745708b59 volume01]# touch 111
[root@642745708b59 volume01]# ls
111
多个数据库数据共享
[root@localhost ~]# docker run -d -p 3310:3306 -v /etc/mysql/conf.d -v /var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 --name mysql1 mysql
af00c2b01ed2999d6f5c45801e0047c0f7ef1fd6899410f7df56f85869cbc950
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
af00c2b01ed2 mysql "docker-entrypoint.s…" 8 seconds ago Up 7 seconds 33060/tcp, 0.0.0.0:3310->3306/tcp, :::3310->3306/tcp mysql1
[root@localhost ~]# docker run -dit -p 3333:3306 -e MYSQL_ROOT_PASSWORD=123456 --name mysql303 --volumes-from mysql1 mysql /bin/bash
a0db4cffea5bc17dc934e4836893acda9e99288986777478bdca70630293ce83
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a0db4cffea5b mysql "docker-entrypoint.s…" 10 seconds ago Up 8 seconds 33060/tcp, 0.0.0.0:3333->3306/tcp, :::3333->3306/tcp mysql303
af00c2b01ed2 mysql "docker-entrypoint.s…" 11 minutes ago Up 11 minutes 33060/tcp, 0.0.0.0:3310->3306/tcp, :::3310->3306/tcp mysql1
标签:容器,root,tcp,volume01,mysql,3306,docker,数据 From: https://www.cnblogs.com/muxinq/p/18221267