2

I have set up GitLab on docker container (from gitlab/gitlab-ce). did apt-get install postfix inside container.

Now when I restart container, postfix is not started (through in /etc/rc2.d/ there is S01postfix link).

Question: how do I start services in container (like postfix) when docker container (re)starts?

OscarAkaElvis
  • 5,384
  • 4
  • 27
  • 51
dockter c
  • 21
  • 1
  • 1
    Generally you run them in separate containers; multiple services in a single container isn’t usually a best practice. That’s doubly true when the other service is something like an SMTP relay with a well-defined network interface. – David Maze Nov 14 '18 at 15:25

1 Answers1

0

You should re-build the container. Do you have the Dockerfile? if yes, you can modify it not only to add your service, you'll need to set an ENTRYPOINT to launch postfix while CMD passed as argument will launch gitlab.

But as somebody said in comments, this is a dirty solution. It should be separated containers.

Another "dirty" solution could be this: https://docs.docker.com/config/containers/multi-service_container/

Using the stuff of this last link (supervisord) you can use a wrapper to launch two ore more services inside the same container.

OscarAkaElvis
  • 5,384
  • 4
  • 27
  • 51
  • If you specify an ENTRYPOINT, only that gets run, and it gets passed the CMD as arguments. You can’t use separate ENTRYPOINT and CMD to start two things in one container (without doing the heavy lifting in the ENTRYPOINT). – David Maze Nov 14 '18 at 15:43
  • It can be done. It's a bad practice but it can be done. You can start some stuff on ENTRYPOINT and then run the CMD. Try it you can set ENTRYPOINT and then pass arguments as you said to run CMD stuff. – OscarAkaElvis Nov 14 '18 at 15:44
  • I found another "dirty" solution, I'll edit my answer. – OscarAkaElvis Nov 14 '18 at 15:47