Dockerfile for Gluster... Can't get the service to start when the container is created

283 Views Asked by At

Current dockerfile:

FROM ubuntu:latest

RUN apt-get update && \
    apt-get install -y software-properties-common && \
    add-apt-repository ppa:gluster/glusterfs-9 && \
    apt-get update && \
    apt-get install -y glusterfs-server

CMD ["/usr/sbin/init"]

Using this, the container starts perfectly... However the service being installed (Gluster) doesn't start.

I've tried combinations of RUN, CMD, & ENTRYPOINT scripts executing variations of "service glusterd start" (the command to start the Gluster daemon) but those combinations:

  • Cause the container to exit on creation
  • Cause errors that crash the container

I can confirm "service glusterd start" is the correct command that needs to be run, as:

  • I can SSH into the running container/pod
  • Confirm that the Gluster daemon is not running
  • Run "service glusterd start" in the container/pod without errors
  • Confirm that the Gluster daemon has started after running "service glusterd start"

Any ideas on how to execute "service glusterd start" at the container creation in the dockerfile?

1

There are 1 best solutions below

0
Chase Westlye On BEST ANSWER

Real credit goes to DaveMaze in the comments... His note about service/systemctl and CMD lead me down a path that ended up working:

FROM ubuntu:latest

RUN apt-get update && \
    apt-get install -y software-properties-common && \
    add-apt-repository ppa:gluster/glusterfs-9 && \
    apt-get update && \
    apt-get install -y glusterfs-server

CMD glusterd -N

Works perfectly.