Issue

This article is for those that have found issues when implementing Azure SSH involving a Docker web server image. One of the primary indications that Azure SSH may be conflicting with your application server startup is the ability to only start one or the other.

Example

When searching through most web server images, an execution command can be typically found. For example, if php:8.1-apache-buster was used as the base image of the custom Dockerfile:

The following command can be seen layered within the Dockerfile, which starts a script to run the web server:

Solution

A Dockerfile will only execute the last CMD operation even when the CMD is layered within the image. To start both servers, configure the SSH in accordance with the following Microsoft documentation: https://learn.microsoft.com/. After the configuration is complete, edit the entrypoint.sh file and add the web server start command under the ‘service ssh start’:

The ‘service apache2 start’ should be replaced with the execution command appropriate to the webserver image.

In an engagement with a client, the ‘gunicorn’ command was not used but still worked as intended.

Summary

The ‘run SSH’ server command may be stopping the ‘start web server’ command. A potential fix may be to create a script that starts both servers to ensure they are running together. There can only be one CMD command in a Dockerfile.