Compose not working with Dockerfile using FROM

Right now, I am using a docker-compose file that contains, amongst other stuff, a few lines like this. This executes without any sort of problem. It deploys perfectly and I’m able to access the web server inside through the browser.

  container:
    command: bash -c "cd /code; chmod +x ./deploy/start_dev.sh; ./deploy/start_dev.sh;"
    image: python:3.6

As I needed to be able to connect to the container through SSH I created a Dockerfile that installs it and modifies the config file so it allows unsafe root connections:

  • Monitoring changes at mounted a host directory from Docker container
  • Can't set custom configuration file for mysql docker container
  • How to search images from private 1.0 registry in docker?
  • AWS Network ACL Rules for Docker
  • How to run basic web app container in docker-py?
  • Why does Volumes of CreateContainerOptions take a map[string]struct{}?
  • FROM python:3.6
    
    RUN apt-get update && apt-get install openssh-server -y
    RUN sed -i "s/PermitRootLogin without-password/PermitRootLogin yes/g" /etc/ssh/sshd_config
    RUN sed -i "s/PermitEmptyPasswords no/PermitEmptyPasswords yes/g" /etc/ssh/sshd_config
    RUN service ssh restart
    RUN echo "root:sshpassword" | chpasswd
    
    ENTRYPOINT ["/bin/sh", "-c"]
    CMD ["/bin/bash"]
    

    After that I changed the docker-compose file to:

    container:
        command: bash -c "cd /code; chmod +x ./deploy/start_dev.sh; ./deploy/start_dev.sh;"
        build:
            context: .
    

    From this moment on, whenever I run docker-compose up I get the following output:

    container exited with code 0
    

    Is there something I am missing?

  • Docker on Windows (Boot2Docker) - certificate signed by unknown authority error
  • Cross-Host Communication: Ambassador pattern versus port exposition
  • Why docker build image from docker file will create container when build exit incorrectly?
  • Unable to connect to dockerized mysql db remotely
  • How do I get Apache and tomcat docker containers to talk to each other?
  • Running Maven inside a Cloud9 Docker container
  • 2 Solutions collect form web for “Compose not working with Dockerfile using FROM”

    Solved it switching the last two lines of the Dockerfile

    ENTRYPOINT ["/bin/sh", "-c"]
    CMD ["/bin/bash"]    
    

    to

    CMD ["/bin/bash", "-c", "/bin/bash"]
    

    In your docker-compose.yaml file, add the following parameter (under the ‘container’ section):

    tty: true
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.