Issue getting memcache container to automatically start in Docker

I have a container that is being built that only really contains memcached, and I want it to start once the container is built.

This is my current Docker file –

  • does the FROM directive in a dockerfile allways pull the latest version of an image
  • docker os container vs app container
  • Sentry Docker Port 80
  • How to edit code in a Docker container in development?
  • package.json file won't persist in docker container
  • Workaround to docker run “--env-file” supplied file not being evaluated as expected
  • FROM centos:7
    MAINTAINER Some guy <>
    RUN yum update -y
    RUN yum install -y git
    RUN yum install -y ansible && yum clean all -y
    RUN yum install -y memcached
    RUN (cd /lib/systemd/system/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
    rm -f /lib/systemd/system/*;\
    rm -f /etc/systemd/system/*.wants/*;\
    rm -f /lib/systemd/system/*; \
    rm -f /lib/systemd/system/*udev*; \
    rm -f /lib/systemd/system/*initctl*; \
    rm -f /lib/systemd/system/*;\
    rm -f /lib/systemd/system/*;
    VOLUME [ "/sys/fs/cgroup" ]
    EXPOSE 11211/tcp 11211/udp
    CMD ["/usr/bin/memcached"]
    #CMD ["/usr/bin/memcached -u root"]
    #CMD ["/usr/bin/memcached", "-D", "FOREGROUND"]

    The container builds successfully, but when I try to run the container using the command

    docker run -d -i -t -P <image id>, I cannot see the image inside of the list that is returned with docker ps.

    I attempted to have my memcached service run the same way as my httpd container, but I cannot pass in the argument using the -D flag (since its already a daemon im guessing). This is how my httpd CMD was set up –

    CMD ["/usr/sbin/httpd", "-D", "FOREGROUND"]

    Locally, if I run the command /usr/bin/memcached -u root it runs as a process, but when I try in the container CMD it informs me that it cannot find the specified file (having to do with the -u root section I am guessing).

    Setting the CMD to /bin/bash still did not allow the service to start either.

    How can I have my memcached service run and allow it to be seen when I run docker ps, so that I can open a bash section inside of it?


  • How to copy image into VS2015 in order to amend code
  • How to deploy node app to docker using maven
  • swift 3.1.1.-release on linux copyItem(atPath:toPath:) is not yet implemented
  • run docker commands from command prompt versus jenkins script
  • How to build and run a java instance in Docker
  • VSTS Docker Integration fails to install
  • 2 Solutions collect form web for “Issue getting memcache container to automatically start in Docker”

    memcached will run in the foreground by default, which is what you want. The -d option would run memcached as a daemon which would cause the container to exit immediately.

    The Dockerfile looks overly complex, try this

    FROM centos:7
    RUN yum update -y && yum install -y epel-release && yum install -y memcached && yum clean all
    EXPOSE 11211
    CMD ["/usr/bin/memcached","-p","11211","-u","memcached","-m","64"]

    Then you can do what you need

    $ docker build -t me/memcached .
    <snipped build>
    $ CID=$(docker create me/memcached)
    $ docker start $CID
    $ docker ps
    CONTAINER ID        IMAGE                         COMMAND                  CREATED              STATUS              PORTS                    NAMES
    4ac5afed0641        me/memcached                  "/usr/bin/memcached -"   About a minute ago   Up 4 seconds        11211/tcp                jovial_bardeen
    $ docker exec $CID ps -ef
    UID        PID  PPID  C STIME TTY          TIME CMD
    memcach+     1     0  0 01:03 ?        00:00:00 /usr/bin/memcached -p 11211 -u memcached -m 64
    root        10     0  2 01:04 ?        00:00:00 ps -ef
    $ docker exec -ti $CID bash
    [root@4ac5afed0641 /]# 

    Or skip your Dockerfile if it actually only runs memcached and use:

    docker run --name my-memcache -d memcached

    At least to get your basic set-up going, and then you can update that official image as needed.

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