Docker Container is started but not runing
#1
Following is my Docker compose file. I have used the Jenkins images to install Jenkins. Within the same file,I have defined another container from which I can SSH and connect with the Jenkins server.

Docker Compose File

version: '3'
services:
  jenkins:
    container_name: jenkins
    image: jenkins/jenkins
    ports:
      - "8080:8080"
    volumes:
      - "$PWD/jenkins_home:/var/jenkins_home"
    networks:
      - net
  remote_host:
    container_name: remote-host
    image: remote-host
    build:
      context: centos
    networks:
      - net
networks:
  net:
Created another folder name Centos and created Dockerfile within it.

FROM centos:7

RUN yum -y install openssh-server

RUN useradd remote_user && \
    echo remote_user:1234 | chpasswd && \
    mkdir /home/remote_user/.ssh && \
    chmod 700 /home/remote_user/.ssh

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

RUN chown remote_user:remote_user -R /home/remote_user/.ssh && \
    chmod 600 /home/remote_user/.ssh/authorized-key

RUN /usr/sbin/sshd-keygen

CMD /usr/sbin/ssh -D
I ran following command docker-compose build

Output

=> [internal] load build definition from Dockerfile                                                                                                        0.0s
=> => transferring dockerfile: 32B                                                                                                                          0.0s
=> [internal] load .dockerignore                                                                                                                            0.0s
=> => transferring context: 2B                                                                                                                              0.0s
=> [internal] load metadata for docker.io/library/centos:7                                                                                                  0.7s
=> [1/6] FROM docker.io/library/centos:7@sha256:c73f515d06b0fa07bb18d8202035e739a494ce760aa73129f60f4bf2bd22b407                                            0.0s
=> [internal] load build context                                                                                                                            0.0s
=> => transferring context: 36B                                                                                                                            0.0s
=> CACHED [2/6] RUN yum -y install openssh-server                                                                                                          0.0s
=> CACHED [3/6] RUN useradd remote_user &&    echo remote_user:1234 | chpasswd &&    mkdir /home/remote_user/.ssh &&    chmod 700 /home/remote_user/.ss  0.0s
=> CACHED [4/6] COPY remote-key.pub /home/remote_user/.ssh/authorized-key                                                                                  0.0s
=> CACHED [5/6] RUN chown remote_user:remote_user -R /home/remote_user/.ssh &&    chmod 600 /home/remote_user/.ssh/authorized-key                          0.0s
=> CACHED [6/6] RUN /usr/sbin/sshd-keygen                                                                                                                  0.0s
=> exporting to image                                                                                                                                      0.0s
=> => exporting layers                                                                                                                                      0.0s
=> => writing image sha256:fcaaebf103d6674134a68c23f92e2946b9395e2a970b3c2e78c59b9a18fec8be                                                                0.0s
=> => naming to docker.io/library/remote-host
then I ran following command docker-compose up -d

Output

[+] Running 2/2
⠿ Container jenkins      Running                                                                                                                            0.0s
⠿ Container remote-host  Started 
When I run docker images, I can see remote-host

REPOSITORY        TAG      IMAGE ID      CREATED        SIZE
remote-host      latest    fcaaebf103d6  25 hours ago  367MB
jenkins/jenkins  latest    97d23cbbfa56  5 days ago    463MB
but when I run docker ps, I do not see the running container.

CONTAINER ID  IMAGE            COMMAND                  CREATED        STATUS        PORTS                              NAMES
06aa0ceabb18  jenkins/jenkins  "/sbin/tini -- /usr/…"  39 hours ago  Up 37 hours  0.0.0.0:8080->8080/tcp, 50000/tcp  jenkins
docker ps -a

CONTAINER ID  IMAGE            COMMAND                  CREATED          STATUS                      PORTS                              NAMES
dbd2c2b9cecb  jenkins/jenkins  "/sbin/tini -- /usr/…"  30 minutes ago  Up 30 minutes                0.0.0.0:8080->8080/tcp, 50000/tcp  jenkins
812216a3c8e9  remote-host      "/bin/sh -c '/usr/sb…"  30 minutes ago  Exited (127) 7 minutes ago 
Can someone tell me where did I make mistake?
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Docker-CE on a Pine64 amarbl 3 7,983 10-16-2018, 05:52 AM
Last Post: maumoura
  Docker aarch64 on Rock64 douglasmiranda 1 5,528 12-23-2017, 01:49 AM
Last Post: xnathanh
  Rock64 / OMV / Docker jata 3 6,028 11-07-2017, 03:31 AM
Last Post: digitaldaz

Forum Jump:


Users browsing this thread: 1 Guest(s)