1.在windows上安装 docker toolbox(安装过程省略....)
2.打开Kitematic(docker的图形界面工具,在第一步会自动安装好),搜索mongo,找到官方的镜像直接创建,创建后就会自动启动docker了
在图形界面中可以看到,mongo现在是在192.168.99.100:32771运行
现在已经可以用Robo 3T连接mongo数据库了,但是有一个问题就是只能在自己电脑上连上
3.我们用一个nginx代理
下载nginx,解压缩,在conf/nginx.conf的最后面增加tcp代理配置代码
docker exec -it 容器ID /bin/bash #同docker attach很像 -t传递给容器tty终端 -i是interactive,表示可以交互
docker pull 容器镜像名 #拉取容器镜像到本地
docker run -p local-port:container-port -v ... --name container-name -d image-name #创建容器并且启动运行,同一个容器名只能被创建一次,我习惯直接用Kitematic图形界面工具启动容器
docker-ubuntu镜像简单加工,从官方镜像拉取到本地创建容器运行后
apt-get update
apt-get install vim
#apt-get设置使用阿里镜像
cd /etc/apt
cp sources.list sources.list.bak #先备份一下
vi sources.list #ggVG全选,d删除, i进入insert模式,复制下面的代码粘贴,esc退出编辑模式,:wq保存退出
阿里镜像代理代码
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
apt-get update
apt-get install openssh-server openssh-client
apt-get install default-jdk #安装java1.8,JAVA_HOME=/usb/lib/jvm/default-java
最后 docker commit -m="ubuntu install vim,ssh,jdk" ubuntu,提交更新到本地镜像
docker centos
yum install crontabs.noarch #安装cron
yum install openssh-clients
yum install sshpass
service直接去掉了,没必要去执行initscript来安装service命令了,因为本身有BUG,service命令不能启动其它程序