获取镜像:
[root@docker ~]# docker pull centos:7
Trying to pull repository docker.io/library/centos ...
7: Pulling from docker.io/library/centos
3d8673bd162a: Pull complete
Digest: sha256:a66ffcb73930584413de83311ca11a4cb4938c9b2521d331026dad970c19adf4
Status: Downloaded newer image for docker.io/centos:7
[root@docker ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/centos 7 970633036444 2 weeks ago 196.7 MB
docker.io/debian 7 dc81f1af026c 2 weeks ago 84.9 MB
docker.io/centos 6.6 2c886f766286 6 weeks ago 202.6 MB
----------------------------------------------------------------------------------------------------
docker pull <镜像名:tag> #从官网拉取镜像
docker search <镜像名> #搜索在线可用镜像名
-----------------------------------------------------------------------------------------------------
删除镜像:
[root@docker ~]# docker rmi 2c886f766286
Untagged: docker.io/centos:6.6
Deleted: sha256:2c886f766286449b76ad90a7ce577b988e48fe5a3ed9a75c53fb81f783946831
Deleted: sha256:c1acbd321a478f30cea685bddad3d1d44e70e5054e855b86ed1354fb95f64698
[root@docker ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/centos 7 970633036444 2 weeks ago 196.7 MB
docker.io/debian 7 dc81f1af026c 2 weeks ago 84.9 MB
验证下载的镜像是否正确:
[root@docker ~]# docker run -i -t debian /bin/bash
Unable to find image 'debian:latest' locally
Trying to pull repository docker.io/library/debian ...
latest: Pulling from docker.io/library/debian
357ea8c3d80b: Pull complete
Digest: sha256:ffb60fdbc401b2a692eef8d04616fca15905dce259d1499d96521970ed0bec36
Status: Downloaded newer image for docker.io/debian:latest
root@
c9754d098c8f
:/#
[root@docker ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c9754d098c8f debian "/bin/bash" 29 seconds ago Up 27 seconds gloomy_liskov
[root@docker ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c9754d098c8f debian "/bin/bash" 2 minutes ago Up 2 minutes gloomy_liskov
root@c9754d098c8f:/# exit //如果镜像退出
exit
[root@docker ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@docker ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c9754d098c8f debian "/bin/bash" 4 minutes ago Exited (0) About a minute ago gloomy_liskov
---------------------------------------------------------------------------------------------------
docker top #显示容器内运行的进程
docker images #查询所有的镜像,默认是最近创建的排在最上。
docker ps #查看正在运行的容器
docker ps -l #查看最后退出的容器的ID
docker ps -a #查看所有的容器,包括退出的。
docker logs {容器ID|容器名称} #查询某个容器的所有操作记录。
docker logs -f {容器ID|容器名称} #实时查看容易的操作记录。
---------------------------------------------------------------------------------------
//删除正在运行的容器
[root@docker ~]# docker rm $(docker ps -a -q)
5ee5f7a43c08
ef38c124fc8c
7ab0bf5a2e38
78d21bf30c41
682579ac4d61
3cd0a71f5ca8
c9754d098c8f
da1c585c416c
bebe5e0d6c44
6c7bd146682b
[root@docker ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
-------------------------------------------------------------------------------------------------------
docker rm$(docker ps -a -q) #删除所有容器
docker rm <容器名or ID> #删除单个容器
docker rmi #删除单个镜像
docker rmi$(docker images | grep none | awk '{print $3}' | sort -r)
------------------------------------------------------------------------------------------
//复制一个镜像
[root@docker mydockerbuild]# docker tag bb1a16c6f475 maryatdocker/docker-whale:latest
[root@docker mydockerbuild]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker-whale latest bb1a16c6f475 2 minutes ago 256.2 MB
maryatdocker/docker-whale latest bb1a16c6f475 2 minutes ago 256.2 MB
docker.io/hello-world latest c54a2cc56cbb 6 weeks ago 1.848 kB
docker.io/docker/whalesay latest 6b362a9f73eb 14 months ago 247 MB
创建镜像:
[root@docker ~]# docker run -i -t centos:6.6 /bin/bash
[root@61497d87b800 /]# touch test
[root@61497d87b800 /]# ls
bin dev etc home lib lib64 lost+found media mnt opt proc root run sbin selinux srv sys
test
tmp usr var
[root@61497d87b800 /]# exit
exit
[root@docker ~]# docker commit -m "added a new file" -a "Docker cxp"
docker: "commit" requires a minimum of 1 argument.
See '/usr/bin/docker-current commit --help'.
Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
Create a new image from a container's changes
[root@docker ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/centos 7 970633036444 2 weeks ago 196.7 MB
docker.io/debian 7 dc81f1af026c 2 weeks ago 84.9 MB
docker.io/debian latest 1b01529cc499 2 weeks ago 125.1 MB
docker.io/centos 6.6 2c886f766286 6 weeks ago 202.6 MB
----------------------------------------------------------------------------------------
参数:
-a, --author=””作者信息
-m,--message=””提交信息
-p,--pause=true提交时暂停容器运行
----------------------------------------------------------------------------------------
创建镜像:
[root@docker ~]# docker create debian:7
[root@docker ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/debian 7 dc81f1af026c 2 weeks ago 84.9 MB
进入容器:
导出容器:
[root@docker ~]# docker export 31556cc3c436 > /opt/debian.tar
[root@docker ~]# ls /opt/debian.tar
/opt/debian.tar
安装:
[root@docker ~]# yum install net-tools
查看本系统IP地址:
安装仓库:
[root@docker ~]# docker pull registry
Using default tag: latest
Trying to pull repository docker.io/library/registry ...
latest: Pulling from docker.io/library/registry
e110a4a17941: Pull complete
2ee5ed28ffa7: Pull complete
d1562c23a8aa: Pull complete
06ba8e23299f: Pull complete
802d2a9c64e8: Pull complete
Digest: sha256:1b68f0d54837c356e353efb04472bc0c9a60ae1c8178c9ce076b01d2930bcc5d
Status: Downloaded newer image for docker.io/registry:latest
[root@docker ~]# docker run -d -p 5000:5000 -v /opt/data/registry:/tmp/registry registry
c3972270fc5d2f68cb7beeee7ddbde2471b37055f18d934c9473be278f0a325b
[root@docker ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c3972270fc5d registry "/entrypoint.sh /etc/" 15 seconds ago Up 13 seconds 0.0.0.0:5000->5000/tcp tender_bartik
使用服务器的ip地址 测试一下我们自己的私有仓库好不好用 执行curl
http://12.8.0.11:5000
[root@docker ~]# curl
http://12.8.0.11:5000
--------------------------------------------------------------------------------------------------------
docker搭建tomcat集群:
[root@docker ~]# docker run -it -p 48080:8080 -v /root/software/:/mnt/software/ --name tomcat1 2c88 /bin/bash
[root@docker ~]# docker run -it -p 58080:8080 -v /root/software/:/mnt/software/ --name tomcat2 2c88 /bin/bash
----------------------------------------------------------------------------------------------------------------------------------
docker搭建Mysql主从
[root@docker ~]# docker pull hub.c.163.com/nce2/mysql:5.6
Trying to pull repository hub.c.163.com/nce2/mysql ...
5.6: Pulling from hub.c.163.com/nce2/mysql
f4ab0b34ba6a: Pull complete
ec98cd60600f: Pull complete
a3ed95caeb02: Pull complete
396e622170d4: Pull complete
65d62a084566: Pull complete
6bbdcff5fa60: Pull complete
edc2e7792fdc: Pull complete
fda4a67523f7: Pull complete
64392f90df87: Pull complete
3f1300a78a30: Pull complete
a34550f73a87: Pull complete
c42721b9b9d7: Pull complete
f4c4bad7c45c: Pull complete
c00368654739: Pull complete
be24f7e4c4c8: Pull complete
832a2ceeea32: Pull complete
Digest: sha256:1c0c33bc6f801b1f6ed03a180dc5ff31abbfff9d587ffe2bd40006b506b81536
Status: Downloaded newer image for hub.c.163.com/nce2/mysql:5.6
创建mysql5.6容器 1master+3个slave
[root@docker ~]# docker run --name mysql-master -d -P hub.c.163.com/nce2/mysql:5.6
53d9dd333004e725a0bffffbaa531a473875fffb519813250f860220c0794b77
[root@docker ~]# docker run --name mysql-slave1 -d -P hub.c.163.com/nce2/mysql:5.6
946ea0bf25af0373e331c64c024e302bbb570f46dc114f7881b65001bbef7302
[root@docker ~]# docker run --name mysql-slave2 -d -P hub.c.163.com/nce2/mysql:5.6
c36247b619acc2269ed07abeebcd287992bfc73f889fca7a4d976a38e896f478
[root@docker ~]# docker run --name mysql-slave3 -d -P hub.c.163.com/nce2/mysql:5.6
47f57e8dccc7a8093270949a5be805fc20e49a5707a26867bcb107510e5b23b9
[root@docker ~]#
通过主机命令行进入master容器
[root@docker ~]# docker exec -it mysql-master bash
root@53d9dd333004:/#
在master中创建一个数据库test_docker
root@53d9dd333004:/# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.19-v1-log MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| #bak_database |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.00 sec)
mysql> create database test_docker;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| #bak_database |
| mysql |
| performance_schema |
| test |
| test_docker |
+--------------------+
6 rows in set (0.00 sec)
mysql> quit
root@53d9dd333004:/# cd /etc/
root@53d9dd333004:/etc/apt# echo deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse >> sources.list
root@53d9dd333004:/etc/apt# echo deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse >> sources.list
root@53d9dd333004:/etc/apt# echo deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse >> sources.list
root@53d9dd333004:/etc/apt# echo deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse >> sources.list
root@53d9dd333004:/etc/apt# echo deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse >> sources.list
root@53d9dd333004:/etc/apt# echo deb-src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse >> sources.list
root@53d9dd333004:/etc/apt# echo deb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse >> sources.list
root@53d9dd333004:/etc/apt# echo deb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse >> sources.list
root@53d9dd333004:/etc/apt# echo deb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse >> sources.list
root@53d9dd333004:/etc/apt# echo deb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse >> sources.list
root@53d9dd333004:/etc/apt# apt-get update
Ign http://mirrors.163.com trusty InRelease
Get:1 http://mirrors.163.com trusty-updates InRelease [65.9 kB]
Get:2 http://mirrors.163.com trusty-security InRelease [65.9 kB]
Get:3 http://mirrors.163.com trusty-proposed InRelease [65.9 kB]
Get:4 http://mirrors.163.com trusty-backports InRelease [65.9 kB]
Get:5 http://mirrors.163.com trusty Release.gpg [933 B]
Get:6 http://mirrors.163.com trusty Release [58.5 kB]
Get:7 http://mirrors.163.com trusty-updates/main Sources [380 kB]
Get:8 http://mirrors.163.com trusty-updates/restricted Sources [5360 B]
Get:9 http://mirrors.163.com trusty-updates/universe Sources [163 kB]
Get:10 http://mirrors.163.com trusty-updates/multiverse Sources [7137 B]
Get:11 http://mirrors.163.com trusty-updates/main amd64 Packages [889 kB]
Get:12 http://mirrors.163.com trusty-updates/universe amd64 Packages [373 kB]
Get:13 http://mirrors.163.com trusty-updates/restricted amd64 Packages [15.9 kB]
Get:14 http://mirrors.163.com trusty-updates/multiverse amd64 Packages [14.8 kB]
Get:15 http://mirrors.163.com trusty-security/main Sources [119 kB]
Get:16 http://mirrors.163.com trusty-security/restricted Sources [4064 B]
Get:17 http://mirrors.163.com trusty-security/universe Sources [41.5 kB]
Get:18 http://mirrors.163.com trusty-security/multiverse Sources [2760 B]
Get:19 http://mirrors.163.com trusty-security/main amd64 Packages [523 kB]
Get:20 http://mirrors.163.com trusty-security/restricted amd64 Packages [13.0 kB]
Get:21 http://mirrors.163.com trusty-security/universe amd64 Packages [136 kB]
Get:22 http://mirrors.163.com trusty-security/multiverse amd64 Packages [4990 B]
Get:23 http://mirrors.163.com trusty-proposed/main Sources [121 kB]
Get:24 http://mirrors.163.com trusty-proposed/restricted Sources [28 B]
Get:25 http://mirrors.163.com trusty-proposed/universe Sources [17.9 kB]
Get:26 http://mirrors.163.com trusty-proposed/multiverse Sources [28 B]
Get:27 http://mirrors.163.com trusty-proposed/main amd64 Packages [114 kB]
Get:28 http://mirrors.163.com trusty-proposed/restricted amd64 Packages [28 B]
Get:29 http://mirrors.163.com trusty-proposed/universe amd64 Packages [17.7 kB]
Get:30 http://mirrors.163.com trusty-proposed/multiverse amd64 Packages [28 B]
Get:31 http://mirrors.163.com trusty-backports/main Sources [9592 B]
Get:32 http://mirrors.163.com trusty-backports/restricted Sources [28 B]
Get:33 http://mirrors.163.com trusty-backports/universe Sources [35.2 kB]
Get:34 http://mirrors.163.com trusty-backports/multiverse Sources [1898 B]
Get:35 http://mirrors.163.com trusty-backports/main amd64 Packages [13.3 kB]
Get:36 http://mirrors.163.com trusty-backports/restricted amd64 Packages [28 B]
Get:37 http://mirrors.163.com trusty-backports/universe amd64 Packages [43.2 kB]
Get:38 http://mirrors.163.com trusty-backports/multiverse amd64 Packages [1571 B]
Get:39 http://mirrors.163.com trusty/main Sources [1064 kB]
Get:40 http://mirrors.163.com trusty/restricted Sources [5433 B]
Get:41 http://mirrors.163.com trusty/universe Sources [6399 kB]
Get:42 http://mirrors.163.com trusty/multiverse Sources [174 kB]
Get:43 http://mirrors.163.com trusty/main amd64 Packages [1350 kB]
Get:44 http://mirrors.163.com trusty/universe amd64 Packages [5859 kB]
Get:45 http://mirrors.163.com trusty/restricted amd64 Packages [13.0 kB]
Get:46 http://mirrors.163.com trusty/multiverse amd64 Packages [132 kB]
Fetched 18.4 MB in 26s (688 kB/s)
Reading package lists... Done
W: Duplicate sources.list entry http://mirrors.163.com/ubuntu/ trusty/main amd64 Packages (/var/lib/apt/lists/mirrors.163.com_ubuntu_dists_trusty_main_binary-amd64_Packages)
W: Duplicate sources.list entry http://mirrors.163.com/ubuntu/ trusty/universe amd64 Packages (/var/lib/apt/lists/mirrors.163.com_ubuntu_dists_trusty_universe_binary-amd64_Packages)
W: Duplicate sources.list entry http://mirrors.163.com/ubuntu/ trusty-updates/main amd64 Packages (/var/lib/apt/lists/mirrors.163.com_ubuntu_dists_trusty-updates_main_binary-amd64_Packages)
W: Duplicate sources.list entry http://mirrors.163.com/ubuntu/ trusty-updates/universe amd64 Packages (/var/lib/apt/lists/mirrors.163.com_ubuntu_dists_trusty-updates_universe_binary-amd64_Packages)
W: You may want to run apt-get update to correct these problems
root@53d9dd333004:/etc/apt# apt-get install vim
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libgpm2 libpython2.7 vim-common vim-runtime
Suggested packages:
gpm ctags vim-doc vim-scripts
The following NEW packages will be installed:
libgpm2 libpython2.7 vim vim-common vim-runtime
0 upgraded, 5 newly installed, 0 to remove and 52 not upgraded.
Need to get 6994 kB of archives.
After this operation, 32.0 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.163.com/ubuntu/ trusty/main libgpm2 amd64 1.20.4-6.1 [16.5 kB]
Get:2 http://mirrors.163.com/ubuntu/ trusty-updates/main libpython2.7 amd64 2.7.6-8ubuntu0.2 [1039 kB]
Get:3 http://mirrors.163.com/ubuntu/ trusty/main vim-common amd64 2:7.4.052-1ubuntu3 [95.6 kB]
Get:4 http://mirrors.163.com/ubuntu/ trusty/main vim-runtime all 2:7.4.052-1ubuntu3 [4888 kB]
Get:5 http://mirrors.163.com/ubuntu/ trusty/main vim amd64 2:7.4.052-1ubuntu3 [956 kB]
Fetched 6994 kB in 8s (817 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libgpm2:amd64.
(Reading database ... 13727 files and directories currently installed.)
Preparing to unpack .../libgpm2_1.20.4-6.1_amd64.deb ...
Unpacking libgpm2:amd64 (1.20.4-6.1) ...
Selecting previously unselected package libpython2.7:amd64.
Preparing to unpack .../libpython2.7_2.7.6-8ubuntu0.2_amd64.deb ...
Unpacking libpython2.7:amd64 (2.7.6-8ubuntu0.2) ...
Selecting previously unselected package vim-common.
Preparing to unpack .../vim-common_2%3a7.4.052-1ubuntu3_amd64.deb ...
Unpacking vim-common (2:7.4.052-1ubuntu3) ...
Selecting previously unselected package vim-runtime.
Preparing to unpack .../vim-runtime_2%3a7.4.052-1ubuntu3_all.deb ...
Adding 'diversion of /usr/share/vim/vim74/doc/help.txt to /usr/share/vim/vim74/doc/help.txt.vim-tiny by vim-runtime'
Adding 'diversion of /usr/share/vim/vim74/doc/tags to /usr/share/vim/vim74/doc/tags.vim-tiny by vim-runtime'
Unpacking vim-runtime (2:7.4.052-1ubuntu3) ...
Selecting previously unselected package vim.
Preparing to unpack .../vim_2%3a7.4.052-1ubuntu3_amd64.deb ...
Unpacking vim (2:7.4.052-1ubuntu3) ...
Processing triggers for mime-support (3.54ubuntu1.1) ...
Setting up libgpm2:amd64 (1.20.4-6.1) ...
Setting up libpython2.7:amd64 (2.7.6-8ubuntu0.2) ...
Setting up vim-common (2:7.4.052-1ubuntu3) ...
Setting up vim-runtime (2:7.4.052-1ubuntu3) ...
Processing /usr/share/vim/addons/doc
Setting up vim (2:7.4.052-1ubuntu3) ...
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vim (vim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vimdiff (vimdiff) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rvim (rvim) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/rview (rview) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/vi (vi) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/view (view) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/ex (ex) in auto mode
update-alternatives: using /usr/bin/vim.basic to provide /usr/bin/editor (editor) in auto mode
Processing triggers for libc-bin (2.19-0ubuntu6.6) ...
W: Duplicate sources.list entry http://mirrors.163.com/ubuntu/ trusty/main amd64 Packages (/var/lib/apt/lists/mirrors.163.com_ubuntu_dists_trusty_main_binary-amd64_Packages)
W: Duplicate sources.list entry http://mirrors.163.com/ubuntu/ trusty/universe amd64 Packages (/var/lib/apt/lists/mirrors.163.com_ubuntu_dists_trusty_universe_binary-amd64_Packages)
W: Duplicate sources.list entry http://mirrors.163.com/ubuntu/ trusty-updates/main amd64 Packages (/var/lib/apt/lists/mirrors.163.com_ubuntu_dists_trusty-updates_main_binary-amd64_Packages)
W: Duplicate sources.list entry http://mirrors.163.com/ubuntu/ trusty-updates/universe amd64 Packages (/var/lib/apt/lists/mirrors.163.com_ubuntu_dists_trusty-updates_universe_binary-amd64_Packages)
W: You may want to run apt-get update to correct these problems
root@53d9dd333004:/etc/apt# apt-get update
Ign http://mirrors.163.com trusty InRelease
Hit http://mirrors.163.com trusty-updates InRelease
Hit http://mirrors.163.com trusty-security InRelease
Hit http://mirrors.163.com trusty-proposed InRelease
Hit http://mirrors.163.com trusty-backports InRelease
Hit http://mirrors.163.com trusty Release.gpg
Hit http://mirrors.163.com trusty Release
Hit http://mirrors.163.com trusty-updates/main Sources
Hit http://mirrors.163.com trusty-updates/restricted Sources
Hit http://mirrors.163.com trusty-updates/universe Sources
Hit http://mirrors.163.com trusty-updates/multiverse Sources
Hit http://mirrors.163.com trusty-updates/main amd64 Packages
Hit http://mirrors.163.com trusty-updates/universe amd64 Packages
Hit http://mirrors.163.com trusty-updates/restricted amd64 Packages
Hit http://mirrors.163.com trusty-updates/multiverse amd64 Packages
Hit http://mirrors.163.com trusty-security/main Sources
Hit http://mirrors.163.com trusty-security/restricted Sources
Hit http://mirrors.163.com trusty-security/universe Sources
Hit http://mirrors.163.com trusty-security/multiverse Sources
Hit http://mirrors.163.com trusty-security/main amd64 Packages
Hit http://mirrors.163.com trusty-security/restricted amd64 Packages
Hit http://mirrors.163.com trusty-security/universe amd64 Packages
Hit http://mirrors.163.com trusty-security/multiverse amd64 Packages
Hit http://mirrors.163.com trusty-proposed/main Sources
Hit http://mirrors.163.com trusty-proposed/restricted Sources
Hit http://mirrors.163.com trusty-proposed/universe Sources
Hit http://mirrors.163.com trusty-proposed/multiverse Sources
Hit http://mirrors.163.com trusty-proposed/main amd64 Packages
Hit http://mirrors.163.com trusty-proposed/restricted amd64 Packages
Hit http://mirrors.163.com trusty-proposed/universe amd64 Packages
Hit http://mirrors.163.com trusty-proposed/multiverse amd64 Packages
Hit http://mirrors.163.com trusty-backports/main Sources
Hit http://mirrors.163.com trusty-backports/restricted Sources
Hit http://mirrors.163.com trusty-backports/universe Sources
Hit http://mirrors.163.com trusty-backports/multiverse Sources
Hit http://mirrors.163.com trusty-backports/main amd64 Packages
Hit http://mirrors.163.com trusty-backports/restricted amd64 Packages
Hit http://mirrors.163.com trusty-backports/universe amd64 Packages
Hit http://mirrors.163.com trusty-backports/multiverse amd64 Packages
Hit http://mirrors.163.com trusty/main Sources
Hit http://mirrors.163.com trusty/restricted Sources
Hit http://mirrors.163.com trusty/universe Sources
Hit http://mirrors.163.com trusty/multiverse Sources
Hit http://mirrors.163.com trusty/main amd64 Packages
Hit http://mirrors.163.com trusty/universe amd64 Packages
Hit http://mirrors.163.com trusty/restricted amd64 Packages
Hit http://mirrors.163.com trusty/multiverse amd64 Packages
Reading package lists... Done
W: Duplicate sources.list entry http://mirrors.163.com/ubuntu/ trusty/main amd64 Packages (/var/lib/apt/lists/mirrors.163.com_ubuntu_dists_trusty_main_binary-amd64_Packages)
W: Duplicate sources.list entry http://mirrors.163.com/ubuntu/ trusty/universe amd64 Packages (/var/lib/apt/lists/mirrors.163.com_ubuntu_dists_trusty_universe_binary-amd64_Packages)
W: Duplicate sources.list entry http://mirrors.163.com/ubuntu/ trusty-updates/main amd64 Packages (/var/lib/apt/lists/mirrors.163.com_ubuntu_dists_trusty-updates_main_binary-amd64_Packages)
W: Duplicate sources.list entry http://mirrors.163.com/ubuntu/ trusty-updates/universe amd64 Packages (/var/lib/apt/lists/mirrors.163.com_ubuntu_dists_trusty-updates_universe_binary-amd64_Packages)
W: You may want to run apt-get update to correct these problems
root@53d9dd333004:/etc/apt# apt-get install net-tools
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
net-tools
0 upgraded, 1 newly installed, 0 to remove and 52 not upgraded.
Need to get 175 kB of archives.
After this operation, 725 kB of additional disk space will be used.
Get:1 http://mirrors.163.com/ubuntu/ trusty-updates/main net-tools amd64 1.60-25ubuntu2.1 [175 kB]
Fetched 175 kB in 0s (570 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package net-tools.
(Reading database ... 15414 files and directories currently installed.)
Preparing to unpack .../net-tools_1.60-25ubuntu2.1_amd64.deb ...
Unpacking net-tools (1.60-25ubuntu2.1) ...
Setting up net-tools (1.60-25ubuntu2.1) ...
W: Duplicate sources.list entry http://mirrors.163.com/ubuntu/ trusty/main amd64 Packages (/var/lib/apt/lists/mirrors.163.com_ubuntu_dists_trusty_main_binary-amd64_Packages)
W: Duplicate sources.list entry http://mirrors.163.com/ubuntu/ trusty/universe amd64 Packages (/var/lib/apt/lists/mirrors.163.com_ubuntu_dists_trusty_universe_binary-amd64_Packages)
W: Duplicate sources.list entry http://mirrors.163.com/ubuntu/ trusty-updates/main amd64 Packages (/var/lib/apt/lists/mirrors.163.com_ubuntu_dists_trusty-updates_main_binary-amd64_Packages)
W: Duplicate sources.list entry http://mirrors.163.com/ubuntu/ trusty-updates/universe amd64 Packages (/var/lib/apt/lists/mirrors.163.com_ubuntu_dists_trusty-updates_universe_binary-amd64_Packages)
W: You may want to run apt-get update to correct these problems
还有一种方法
可以创建Dockerfile依赖mysql镜像创建一个新的镜像。
上诉命令通过RUN来执行创建的新容器会有安装的软件。
最后通过slave的docker连接到master的容器mysql服务器上
master的服务器mysql账号root赋值权限
root@53d9dd333004:/etc/apt# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.19-v1-log MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> grant all privileges on *.* to root@'%' identified by '';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
在从数据库端验证:
root@946ea0bf25af:/# mysql -uroot -p -h 172.17.0.5
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.6.19-v1-log MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| #bak_database |
| mysql |
| performance_schema |
| test |
| test_docker |
+--------------------+