docker: do not override base image entry point


Flying Well

I want a docker image that can extend the mongo image and have ssh on it. I wrote this line:

FROM mongo

RUN apt-get update && \
    apt-get install -y openssh-server

EXPOSE 22

RUN useradd -s /bin/bash -p $(openssl passwd -1 test) -d /home/nf2/ -m -G sudo test

CMD ["sh", "-c", "service ssh start", "bash"]

This is just the beginning sshand not the beginning mongo. If removed, the last line mongodis executed from the base image .

Is it possible to run two commands in the same image?

Adiii

As mentioned by @David, CMD normally runs a process, so when you override service ssh startit, it won't run Mongo because it will overwrite the base image that CMDruns the Mongo process .

Try the changes CMDto start both processes.

CMD ["sh", "-c", "service ssh start && mongod"]

But you should know if service ssh is stopped for some reason, your container will still keep running, and once the Mongo process is stopped, the container will die. You can verify with the following command

docker run  -dit --name test --rm abc && docker exec -it test bash -c "service ssh status"
ce30fa23eeb07f1e268008cce7566585ba1f98c0a3054cecb145443f3275a0d4
 * sshd is running

renew:

Since mongod will only start the Mongo process and nothing initializing the database will happen, try changing the command used to imitate the database.

FROM mongo
RUN apt-get update && \
    apt-get install -y openssh-server
ENV MONGO_INITDB_ROOT_USERNAME=root
ENV MONGO_INITDB_ROOT_PASSWORD=example
RUN useradd -s /bin/bash -p $(openssl passwd -1 test) -d /home/nf2/ -m -G 
CMD ["sh", "-c", "service ssh start && docker-entrypoint.sh mongod"]

Related


docker: do not override base image entry point

Flying Well I want a docker image that can extend the mongo image and have ssh on it. I wrote this line: FROM mongo RUN apt-get update && \ apt-get install -y openssh-server EXPOSE 22 RUN useradd -s /bin/bash -p $(openssl passwd -1 test) -d /home/nf2/ -

docker: do not override base image entry point

Flying Well I want a docker image that can extend the mongo image and have ssh on it. I wrote this line: FROM mongo RUN apt-get update && \ apt-get install -y openssh-server EXPOSE 22 RUN useradd -s /bin/bash -p $(openssl passwd -1 test) -d /home/nf2/ -

docker: do not override base image entry point

Flying Well I want a docker image that can extend the mongo image and have ssh on it. I wrote this line: FROM mongo RUN apt-get update && \ apt-get install -y openssh-server EXPOSE 22 RUN useradd -s /bin/bash -p $(openssl passwd -1 test) -d /home/nf2/ -

docker: do not override base image entry point

Flying Well I want a docker image that can extend the mongo image and have ssh on it. I wrote this line: FROM mongo RUN apt-get update && \ apt-get install -y openssh-server EXPOSE 22 RUN useradd -s /bin/bash -p $(openssl passwd -1 test) -d /home/nf2/ -

Dockerfile with entry point only from base image

Ashley I have a very simple Dockerfile like this:- FROM my-base-image COPY abc.properties /opt/conf/ Right now, my base image has a docker entry point (at the end of its Dockerfile), but the final image you see doesn't. Is this possible or do we need to have a

Dockerfile with entry point only from base image

Ashley I have a very simple Dockerfile like this:- FROM my-base-image COPY abc.properties /opt/conf/ Right now, my base image has a docker entry point (at the end of its Dockerfile), but the final image you see doesn't. Is this possible or do we need to have a

Dockerfile with entry point only from base image

Ashley I have a very simple Dockerfile like this:- FROM my-base-image COPY abc.properties /opt/conf/ Right now, my base image has a docker entry point (at the end of its Dockerfile), but the final image you see doesn't. Is this possible or do we need to have a

Dockerfile with entry point only from base image

Ashley I have a very simple Dockerfile like this:- FROM my-base-image COPY abc.properties /opt/conf/ Right now, my base image has a docker entry point (at the end of its Dockerfile), but the final image you see doesn't. Is this possible or do we need to have a

Dockerfile with entry point only from base image

Ashley I have a very simple Dockerfile like this:- FROM my-base-image COPY abc.properties /opt/conf/ Right now, my base image has a docker entry point (at the end of its Dockerfile), but the final image you see doesn't. Is this possible or do we need to have a

Dockerfile with entry point only from base image

Ashley I have a very simple Dockerfile like this:- FROM my-base-image COPY abc.properties /opt/conf/ Right now, my base image has a docker entry point (at the end of its Dockerfile), but the final image you see doesn't. Is this possible or do we need to have a

Add the new entry point to the Docker image

Sarah Recently we decided to move one of our services to docker containers. The service is a product of another company and they have provided us with a docker image. However, we need to perform some additional configuration steps in the container entry point.

Add the new entry point to the Docker image

Sarah Recently we decided to move one of our services to docker containers. The service is a product of another company and they have provided us with a docker image. However, we need to perform some additional configuration steps in the container entry point.

Add the new entry point to the Docker image

Sarah Recently we decided to move one of our services to docker containers. The service is a product of another company and they have provided us with a docker image. However, we need to perform some additional configuration steps in the container entry point.

Add the new entry point to the Docker image

Sarah Recently we decided to move one of our services to docker containers. The service is a product of another company and they have provided us with a docker image. However, we need to perform some additional configuration steps in the container entry point.

Add the new entry point to the Docker image

Sarah Recently we decided to move one of our services to docker containers. The service is a product of another company and they have provided us with a docker image. However, we need to perform some additional configuration steps in the container entry point.

Add the new entry point to the Docker image

Sarah Recently we decided to move one of our services to docker containers. The service is a product of another company and they have provided us with a docker image. However, we need to perform some additional configuration steps in the container entry point.

GitHub Actions ignore/override Docker container's entry point

PB I'm trying to port a GitLab pipeline to GitHub Actions, where we use Docker containers to provide the runtime environment. In GitLab we only use line image: $DOCKER_TAG. Images are built by ourselves and they use scripts as entry points ENTRYPOINT ["/run.sh

GitHub Actions ignore/override Docker container's entry point

PB I'm trying to port a GitLab pipeline to GitHub Actions, where we use Docker containers to provide the runtime environment. In GitLab we only use line image: $DOCKER_TAG. Images are built by ourselves and they use scripts as entry points ENTRYPOINT ["/run.sh

Override Webpack 4 entry point

Samson Here is my project directory: -node_modules -src -client -js -styles -views -index.js -webpack.config.js -server -.babelrc -package -package-lock -README.md -webpack.de

How to dynamically set entry point dll in Docker image

low speed We want to use one Dockerfilefor several different projects . The project structure is the same, as far as the Dockerfile is concerned, the only difference is the entrypoint dll. Here's what one Dockerfileof them looks like: FROM mcr.microsoft.com/do

Default Docker entry point

Eugene Dounar: I'm creating an image from another image that has a specific entry point set. But I want my image to have default image. How to reset ENTRYPOINT? I tried the following Dockerfile: FROM some-image ENTRYPOINT ["/bin/sh", "-c"] Unfortunately it do

Docker entry point "not found"

Helge Talvik Soderstrom TL;DR Why does it work when I build a Docker image locally $ docker build -t broker ., but when building in GitLab CI, I get this bash: line 1: /bin/broker: not found? Background/troubleshooting I'm using GitLab CI to deploy a new versi

Default Docker entry point

Eugene Dounar: I'm creating an image from another image that has a specific entry point set. But I want my image to have default image. How to reset ENTRYPOINT? I tried the following Dockerfile: FROM some-image ENTRYPOINT ["/bin/sh", "-c"] Unfortunately it do

Default Docker entry point

Eugene Dounar I'm creating an image from another image that has a specific entry point set. But I want my image to have default image. How to reset ENTRYPOINT? I tried the following Dockerfile: FROM some-image ENTRYPOINT ["/bin/sh", "-c"] Unfortunately it doe

Docker entry point "not found"

Helge Talvik Soderstrom TL;DR Why does it work when I build a Docker image locally $ docker build -t broker ., but when building in GitLab CI, I get this bash: line 1: /bin/broker: not found? Background/troubleshooting I'm using GitLab CI to deploy a new versi

Docker entry point "not found"

Helge Talvik Soderstrom TL;DR Why does it work when I build a Docker image locally $ docker build -t broker ., but when building in GitLab CI, I get this bash: line 1: /bin/broker: not found? Background/troubleshooting I'm using GitLab CI to deploy a new versi

Docker entry point "not found"

Helge Talvik Soderstrom TL;DR Why does it work when I build a Docker image locally $ docker build -t broker ., but when building in GitLab CI, I get this bash: line 1: /bin/broker: not found? Background/troubleshooting I'm using GitLab CI to deploy a new versi

Docker entry point "not found"

Helge Talvik Soderstrom TL;DR Why does it work when I build a Docker image locally $ docker build -t broker ., but when building in GitLab CI, I get this bash: line 1: /bin/broker: not found? Background/troubleshooting I'm using GitLab CI to deploy a new versi