Docker set ipaddress and start services
I have setup docker and create container but problem is i want to bring up on my
LAN IP subnet, I have configured
docker0 has bridged and start
docker -d -b docker0, Now i want to start container with
static IP and start
FROM centos/centos6-latest RUN /sbin/ifconfig eth0 192.168.1.150 RUN /sbin/route add default gw 192.168.1.1 RUN /etc/init.d/mysqld start RUN /etc/init.d/httpd start
[root@server ~]# docker build -t centos/centos6-latest . Sending build context to Docker daemon 146.8 MB Sending build context to Docker daemon Step 0 : FROM centos/centos6-latest ---> 123729f9961b Step 1 : RUN /sbin/ifconfig eth0 192.168.1.150 ---> Running in c722910e1997 SIOCSIFADDR: Permission denied SIOCSIFFLAGS: Permission denied SIOCSIFNETMASK: Permission denied SIOCSIFBROADCAST: Permission denied 2014/12/23 07:03:38 The command [/bin/sh -c /sbin/ifconfig eth0 192.168.1.150] returned a non-zero code: 255
I know you have to start container with
--privileged mode but i don’t know how do i set it with
One Solution collect form web for “Docker set ipaddress and start services”
Docker containers are not full virtual machines.
Network configuration is done at boot, not build. You cannot assign a static ip without an external tool like pipework. I would suggest reading the networking docs. A static IP is not ‘the docker way’.
Also, containers do not typically use a full blown init system. If you must start multiple services, supervisord or runit are common alternatives.
The privileged flag is specified at docker run, not during the build process.