例如,我启动一个像这样的mysql容器:
docker run --name mysql -v /home/xxxxx/mysql-datadir:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=xxxxxxxxxxxxxxx -d mysql
像这样的apache容器:
docker run --name xxxxx --link mysql:mysql -d -p 8085:80 -v /srv/www/xxxxxx.ch/drupal_openenterprise-7:/var/www/html drupal:7
或者像这样的mysql客户端容器:
docker run -it --link mysql:mysql --rm -v /home/xxxxx:/import mysql sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'
在这两种情况下,如果我停止并且rm其中一个容器并且docker logs mysql
没有显示任何明显的东西,则mysql容器会停止运行。
Version: '5.6.26' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
2015-10-14 14:05:15 0 [Note] mysqld (mysqld 5.6.26) starting as process 1 ...
2015-10-14 14:05:15 1 [Note] Plugin 'FEDERATED' is disabled.
2015-10-14 14:05:15 1 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-10-14 14:05:15 1 [Note] InnoDB: The InnoDB memory heap is disabled
2015-10-14 14:05:15 1 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-10-14 14:05:15 1 [Note] InnoDB: Memory barrier is not used
2015-10-14 14:05:15 1 [Note] InnoDB: Compressed tables use zlib 1.2.7
2015-10-14 14:05:15 1 [Note] InnoDB: Using Linux native AIO
2015-10-14 14:05:15 1 [Note] InnoDB: Using CPU crc32 instructions
2015-10-14 14:05:15 1 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-10-14 14:05:15 1 [Note] InnoDB: Completed initialization of buffer pool
2015-10-14 14:05:15 1 [Note] InnoDB: Highest supported file format is Barracuda.
2015-10-14 14:05:15 1 [Note] InnoDB: The log sequence numbers 1625997 and 1625997 in ibdata files do not match the log sequence number 240458309 in the ib_logfiles!
2015-10-14 14:05:15 1 [Note] InnoDB: Database was not shutdown normally!
2015-10-14 14:05:15 1 [Note] InnoDB: Starting crash recovery.
2015-10-14 14:05:15 1 [Note] InnoDB: Reading tablespace information from the .ibd files...
2015-10-14 14:05:15 1 [Note] InnoDB: Restoring possible half-written data pages
2015-10-14 14:05:15 1 [Note] InnoDB: from the doublewrite buffer...
2015-10-14 14:05:16 1 [Note] InnoDB: 128 rollback segment(s) are active.
2015-10-14 14:05:16 1 [Note] InnoDB: Waiting for purge to start
2015-10-14 14:05:16 1 [Note] InnoDB: 5.6.26 started; log sequence number 240458309
2015-10-14 14:05:16 1 [Note] Server hostname (bind-address): '*'; port: 3306
2015-10-14 14:05:16 1 [Note] IPv6 is available.
2015-10-14 14:05:16 1 [Note] - '::' resolves to '::';
2015-10-14 14:05:16 1 [Note] Server socket created on IP: '::'.
2015-10-14 14:05:16 1 [Note] Event Scheduler: Loaded 0 events
2015-10-14 14:05:16 1 [Note] mysqld: ready for connections.
Version: '5.6.26' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)
2015-10-14 14:25:02 0 [Note] mysqld (mysqld 5.6.26) starting as process 1 ...
2015-10-14 14:25:02 1 [Note] Plugin 'FEDERATED' is disabled.
2015-10-14 14:25:02 1 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-10-14 14:25:02 1 [Note] InnoDB: The InnoDB memory heap is disabled
2015-10-14 14:25:02 1 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-10-14 14:25:02 1 [Note] InnoDB: Memory barrier is not used
2015-10-14 14:25:02 1 [Note] InnoDB: Compressed tables use zlib 1.2.7
2015-10-14 14:25:02 1 [Note] InnoDB: Using Linux native AIO
2015-10-14 14:25:02 1 [Note] InnoDB: Using CPU crc32 instructions
2015-10-14 14:25:02 1 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-10-14 14:25:03 1 [Note] InnoDB: Completed initialization of buffer pool
2015-10-14 14:25:03 1 [Note] InnoDB: Highest supported file format is Barracuda.
2015-10-14 14:25:03 1 [Note] InnoDB: The log sequence numbers 1625997 and 1625997 in ibdata files do not match the log sequence number 240515212 in the ib_logfiles!
2015-10-14 14:25:03 1 [Note] InnoDB: Database was not shutdown normally!
2015-10-14 14:25:03 1 [Note] InnoDB: Starting crash recovery.
2015-10-14 14:25:03 1 [Note] InnoDB: Reading tablespace information from the .ibd files...
2015-10-14 14:25:03 1 [Note] InnoDB: Restoring possible half-written data pages
2015-10-14 14:25:03 1 [Note] InnoDB: from the doublewrite buffer...
2015-10-14 14:25:03 1 [Note] InnoDB: 128 rollback segment(s) are active.
2015-10-14 14:25:03 1 [Note] InnoDB: Waiting for purge to start
2015-10-14 14:25:03 1 [Note] InnoDB: 5.6.26 started; log sequence number 240515212
2015-10-14 14:25:03 1 [Note] Server hostname (bind-address): '*'; port: 3306
2015-10-14 14:25:03 1 [Note] IPv6 is available.
2015-10-14 14:25:03 1 [Note] - '::' resolves to '::';
2015-10-14 14:25:03 1 [Note] Server socket created on IP: '::'.
2015-10-14 14:25:03 1 [Note] Event Scheduler: Loaded 0 events
2015-10-14 14:25:03 1 [Note] mysqld: ready for connections.
Version: '5.6.26' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL)