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 httpd and mysqld services.

Dockerfile:

  • Docker-machine's container contact application on Mac host
  • Creating a Private Docker Registry with Authentication
  • SSH connection to my container closed by remote host
  • Unable to view rails app running in docker container from browser
  • Bind physical NICs to containers for docker
  • Apache Mesos,MESOS-DNS, MARATHON and Docker
  • 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
    

    Error:

    [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 build option

  • How to pull docker image with marathon which need to be authorized
  • How can I define my ENV variables once in the DockerFile and pass them down to my spark image which is submitted by a supervisord managed script?
  • How do apply Puppet class locally
  • How to publish a port different from the default one?
  • docker registry v2, where do buffered or pushed images get stored
  • How to use Docker Remote API to assign a static IP address to a container
  • 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.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.