I cannot use the shell in Docker-Compose

Asked

Viewed 84 times

-1

I am developing a Python application with MYSQL in Docker-Compose, but it is not a web application, would it have any way to run this application in the container by shell ? if there is, you could explain to me how?

if it wasn’t for Docker Compose: I would use the command:

Docker run -it project name And this command would release the container shell

if you have no way to run the shell through Docker-Compose, as you would to communicate a MYSQL image with my application image??

  • 1

    Welcome to Sopt. Please add your Docker to the question, so other people can point out what needs to be changed.

1 answer

0

After the container has gone up, you can activate a shell within it (already running), using docker exec instead of docker run:

docker exec -it nome-do-projeto /bin/bash

  • Thank you ! but would have some command that I could use in Dockerfile or Docker-Compose that already starts in interactive mode, as soon as I climbed the container. It is of paramount importance that answer, , the application only runs in the shell, and is giving error when climbing, because of this!

  • the docer-Compose is meant to be called "outside" of the Docker - there would have been no point in calling the Docker-Compose to climb the containers and he "steal" the terminal. What you can do is another script, short - can only have two lines, which calls the Docker-Compose and runs the exec Docker as above. if you simply put the commands below each other, this is a valid shell script. On the first line put #! /bin/sh, second line, docker-compose up (or whatever you’re using) and last line docker exec ... - change script to executable with chmod o+x <nome>

  • All right, I’ll follow your lead, Muto Thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.