skip to Main Content

I have created a 2 containers in docker. However, one of them is visible and other is not.
Context:
I have created 1 container by downloading the docker jenkins image file and that is up and running and can be seen using docker ps command.

Then, I have tried to create an Image file to be consumed by the second container.
The script I have used in VI to create image file:

FROM centos

RUN yum -y install openssh-server

RUN yum install -y passwd

RUN useradd remote_user && 
    echo "1234" | passwd remote_user --stdin &&  
    mkdir /home/remote_user/.ssh && 
    chmod 700 /home/remote_user/.ssh

COPY remote-key.pub /home/remote_user/.ssh/authorized_keys

RUN chown remote_user:remote_user -R /home/remote_user/.ssh/ && 
    chmod 600 /home/remote_user/.ssh/authorized_keys

CMD /usr/sbin/sshd -D

The script ran successfully as "docker-compose build" has successfully build the image from the script.

Once it was successfully built, I tried to start the it using:

[jenkins@localhost jenkins-data]$ docker-compose up -d
jenkins is up-to-date
Starting remote-host ... done

Post this, when i am doing :

[jenkins@localhost jenkins-data]$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                               NAMES
5c1ee0507091        jenkins/jenkins     "/sbin/tini -- /usr/…"   5 days ago          Up 5 minutes        0.0.0.0:8080->8080/tcp, 50000/tcp   jenkins

Its only showing me one container running while the remote-host container is not visible.
Any way to ensure if the remote-host container is actually running or is there any issue?

New to docker and jenkins, any lead is highly appreciated. thank you.

2

Answers


  1. docker ps only shows running containers.

    Using docker ps -a you see both running and stopped containers.

    See Docker documentation about ps.

    Probably the remote-host container is not running any more?

    Login or Signup to reply.
  2. Container stopped because of the main process which launched by the CMD command detached and become daemon

    the main process should be attached to the terminal so you have to remove -D from CMD command CMD /usr/sbin/sshd -D or you can follow this approach

    run sshd in detached mode and use while sleep to keep the container
    running

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search