I’m trying to create a custom unifi controller container with a number of extras:
FROM jacobalberty/unifi:latest
RUN apt-get update -y && apt-get upgrade -y && apt-get install incron nano curl -y
ENTRYPOINT echo 'root' >> /etc/incron.allow && service incron start && /bin/bash
When I start this container, incron runs, but unifi does not.
I’ll try to explain what I’m looking for: a standard unifi controller with a local volume, incron to watch a certain file and start the incron service. The incron table is loaded from a local file and the service is running when I “ssh” into the container. Unifi however is not. Without the entrypoint line it does work, but the service does not run and on rebuilding I must always start it by hand.
FROM jacobalberty/unifi:latest # really don't recommend to use the latest tag
RUN apt-get update -y && apt-get upgrade -y && apt-get install incron nano curl -y
COPY docker-entrypoint-extended.sh /usr/local/bin
RUN chmod +x /usr/local/bin/docker-entrypoint-extended.sh
ENTRYPOINT ["/usr/local/bin/docker-entrypoint-extended.sh"]
I have not tested it so if you try it you may need to improve the script.
Since I don’t know incron, I can’t say much about that but usually it is not a good practice to run services in a container like this. IIf you really need to run it as a deamon inside the container, I would try http://supervisord.org/
Thank you, I’ll give that a try. But first: you say to create a file which you call “docker-entrypoint-extended.sh” but I see “docker-entrypoint-custom.sh” in Dockerfile. Shouldn’t these have the same name? And where should I create that file? In the same directory as Dockerfile?
I wanted to call it docker-entrypoint-extended.sh and I forgot it immediatelly… so i wrote “-custom” later. I fixed my previous post, thanks
It’s up to you but I wrote my example assuming that the file is in the root of the build context, which usually means that it is next to the Dockerfile.
Based on your example I’m getting the following error: “/usr/local/bin/docker-entrypoint-extended.sh: line 6: /usr/local/bin/docker-entrypoint: No such file or directory”
I have tried correcting the file by changing “docker-entrypoint” to “docker-entrypoint.sh”, but that resulted in a container that didn’t want to start at all. I did find a file called docker-entrypoint.sh in the /usr/local/bin though when building a container based on the default image.
Is this the full log? I assume these lines only the beginnings of the whole lines. What is it “exuting”? Is there an error code when you list the containers using docker container list --all?
When I have a problem like this, I insert echos before every command. That way I know which command ran and which didn’t. So I checked the original entrypoint and realized it does something similar. The “Executing:” line in your logs shows that it tries to execute the command but it is probably empty.
We changed the original entrypoint and If I remember well, it resets the CMD. Try to add CMD ["unify"] to the end of the Dockerfile:
FROM jacobalberty/unifi:latest # really don't recommend to use the latest tag
RUN apt-get update -y && apt-get upgrade -y && apt-get install incron nano curl -y
COPY docker-entrypoint-extended.sh /usr/local/bin
RUN chmod +x /usr/local/bin/docker-entrypoint-extended.sh
ENTRYPOINT ["/usr/local/bin/docker-entrypoint-extended.sh"]
CMD ["unify"]
“unify” is what the original entrypoint expects as command as default. Otherwise it executes the command as is. When you don’t pass any arguments to the container, the default command is the value of CMD