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:

  • How to insert dockerised cron process in a docker-compose built LEMP stack?
  • How can I get cadvisor (Docker) working with AWS/Debian?
  • Suggestions for carrying out automation using docker
  • Docker says there is already a container with the same name that exists despite there are no containers
  • Access to Docker Container Port
  • Docker swarm multiple managers and workers Vs
  • 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 : Sharing a volume on Windows with Docker toolbox
  • Having problems deploying an go app to docker
  • Project layout with vagrant, docker and git
  • Meteor run server getting error: “Could not locate the bindings file. […]bcrypt[…]”
  • Jelastic Docker Nginx LoadBalancing with Horizontal Auto Scaling
  • AspCore using Docker on Mac
  • 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.