I have an issue in my SSH session with a docker container.
Actually can’t execute any command because of a running process that never gives me hand on the terminal, see output:
[Thu Apr 02 19:39:46.056749 2020] [mpm_prefork:notice] [pid 7] AH00163: Apache/2.4.43 (Unix) PHP/7.3.16 configured -- resuming normal operations
[Thu Apr 02 19:39:46.057465 2020] [core:notice] [pid 7] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
Dockerfile install Apache on Alpine and ends:
ENTRYPOINT [ "/opt/entrypoint.sh" ]
entrypoint.sh:
/usr/sbin/httpd -D FOREGROUND
Any hint how I can get my SSH session working and gives me hand to execute other commands? Thank you.
2
Answers
Actually moving command from my dockerfile to the procfile provided by my hosting provider solved the issue. Dockerfile after this change:
And moved the last instruction to Procfile. After this change the process will be a service published from my container and not an entrypoint that will be executed each time the image built or restarted.
The container paradigm does not promote usage of things like ssh servers. The core concept is that you are only hosting a single isolated process inside the container, in your case ‘httpd’.
in other words, there is no ssh server running inside the apache container, it is only hosting the web server process.
You can use a command like
docker exec <container_name> <command>
, to execute another process in the same container. For example:Which will list the content of the configured working directory in the container.
docker exec
will connect the stdout and stderr in your current terminal session to the stdout and stderr of the container, and execute your command in the environment of the container.This is a good solution for trouble shooting and trying things out. But look for alternatives if you are seeking to permanently change the environment of your contained application. Such as using the Dockerfile.
If you supply some more information about your usecase, I will be happy to make a suggestion.