pipework固定容器ip
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pipework固定容器ip相关的知识,希望对你有一定的参考价值。
pipework是个啥?自己搜索下就知道了。
操作系统64bit
[email protected]:~# cat /etc/issue Ubuntu 14.04 LTS \n \l
下载pipework软件包以及解压
[email protected]:~# wget https://github.com/jpetazzo/pipework/archive/master.zip [email protected]:~# unzip master.zip Archive: master.zip 0633ba9dbce2d336e0f10c46819f3a9fa9c8077b creating: pipework-master/ extracting: pipework-master/.gitignore inflating: pipework-master/LICENSE inflating: pipework-master/README.md inflating: pipework-master/docker-compose.yml creating: pipework-master/doctoc/ inflating: pipework-master/doctoc/Dockerfile inflating: pipework-master/pipework inflating: pipework-master/pipework.spec [email protected]:~# cd pipework-master/ [email protected]:~/pipework-master# cp pipework /usr/local/bin/
运行容器,--net=none指的是不位容器设置网络
[email protected]:~# docker run -itd --name x4 --net=none ubuntu 97753071bf40a538fd5b9c3fbb2c4e631aa0b184244092e91eb32ed5ab7a8247
为容器名字为x4设置ip地址为0.22,172.17.42.1是网关
[email protected]:~# pipework docker0 x4 172.17.0.22/[email protected]
进入容器名字为x4
[email protected]:~# docker-enter x4
查看容器设置的ip地址
[email protected]:~# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 10: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 0a:d0:18:01:1d:50 brd ff:ff:ff:ff:ff:ff inet 172.17.0.22/24 scope global eth1 valid_lft forever preferred_lft forever inet6 fe80::8d0:18ff:fe01:1d50/64 scope link valid_lft forever preferred_lft forever
安装ssh服务,设置配置sshd_config允许root登陆并设置密码。然后重启服务即可
[email protected]:~# apt-get install openssh-server -y
[email protected]:~# /etc/init.d/ssh restart * Restarting OpenBSD Secure Shell server sshd [ OK ]
宿主机登陆容器x4,ip为172.17.0.22
[email protected]:~# ssh [email protected] [email protected]‘s password: Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 3.13.0-24-generic x86_64) * Documentation: https://help.ubuntu.com/ Last login: Mon May 16 11:07:18 2016 from 172.17.42.1
ok就先这样了。容器之间都是能通信的,宿主机也能ssh管理容器了。
本文出自 “村里的男孩” 博客,请务必保留此出处http://noodle.blog.51cto.com/2925423/1774097
以上是关于pipework固定容器ip的主要内容,如果未能解决你的问题,请参考以下文章