GNS3 / gns3-server

GNS3 server
GNU General Public License v3.0
798 stars 263 forks source link

Custom Docker Entrypoints not working #1747

Open jimkoen opened 4 years ago

jimkoen commented 4 years ago

I am writing a docker image based on Ubuntu 18.04 for use with GNS3. I understand that before a container get's started in GNS3 a custom init.sh script is injected into the Container before the first start script. However this seems to be messing with the ENTRYPOINT and CMD tags and consequently makes it impossible to run custom commands on startups.

FROM jimkoen/danet-ubuntu-multipurpose
#add config files
ADD ./interfaces /run/files/interfaces
#add scripts
ADD ./user_creation.sh /run/user_creation.sh
ADD ./entrypoint.sh /run/entrypoint.sh
ADD ./network_conf.sh /run/network_conf.sh
ADD ./on_first_startup_only.sh /run/on_first_startup_only.sh
#execute necessary scripts
RUN chmod +x /run/network_conf.sh
RUN /bin/bash -c "/run/network_conf.sh"
RUN chmod +x /run/user_creation.sh
RUN /bin/bash -c "/run/user_creation.sh"
RUN chmod +x /run/on_first_startup_only.sh
RUN chmod +x /run/entrypoint.sh
ENTRYPOINT ["/bin/bash -c /run/on_first_startup_only.sh", "/bin/bash -c /run/entrypoint.sh"]

When I comment out the entrypoint at the end of the file, the container will start just fine. If I do not however, it will start, then immediately exit with exit code 137 and any attempt to open a console results in said console immediately closing.

Any help would be appreciated.

jimkoen commented 4 years ago

Update: ENTRYPOINT and CMD is also broken for gns3's ubuntu xenial. Why inject busybox in the first place? This feels pretty hacky.

grossmj commented 4 years ago

Why inject busybox in the first place? This feels pretty hacky.

@noplay do you have the reason for this? Thanks :)

julien-duponchelle commented 4 years ago

I don't remember exactly. I think it's related due to fact that we inject our interface into the container instead of relying on Docker networking.

https://github.com/GNS3/gns3-server/blob/master/gns3server/compute/docker/resources/init.sh