question

JorgeGuerra-8909 avatar image
0 Votes"
JorgeGuerra-8909 asked ·

How to connect docker container through SSH after putting it in virtual networks

I was able to connect my custom container through ssh following the instructions https://docs.microsoft.com/en-us/azure/app-service/containers/configure-custom-container#enable-ssh but after I put the App Service in a virtual network it stopped working as the port 2222 changed

azure-webapps
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Grmacjon-MSFT avatar image
0 Votes"
Grmacjon-MSFT answered ·

Hello @JorgeGuerra-8909,

Are you getting any specific error messages? What did the port change to?

Based on this VNet Integration document:

"If you host your app on Linux with the built-in images, regional VNet Integration works without additional changes. If you use Web or Function App for Containers, you must modify your docker image to use VNet Integration. In your docker image, use the PORT environment variable as the main web server's listening port, instead of using a hardcoded port number. The PORT environment variable is automatically set by the platform at the container startup time. If you use SSH, the SSH daemon must be configured to listen on the port number specified by the SSH_PORT environment variable when you use regional VNet Integration. "


·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AndresBarcenas-4856 avatar image
0 Votes"
AndresBarcenas-4856 answered ·

Hello @Grmacjon-MSFT,

Thanks for the detailed info. I am using a Web App service (Containers) in a Virtual Network and it is still not working. In my Dockerfile, I have the following:

ENV PORT=80
ENV PORT_SSH=2222
EXPOSE $PORT $PORT_SSH

Also, SSH is configured to listen on port 2222, the Web App Configurations settings have PORT and SSH_PORT defined and I am still able to SSH onto my container for debugging purposes.

Any ideas?

7903-screen-shot-2020-05-01-at-34750-pm.png



· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @AndresBarcenas-4856,

Are you still facing this issue? I see your issue may have been resolved on this GitHub thread https://github.com/MicrosoftDocs/azure-docs/issues/53869a

0 Votes 0 ·
AndresBarcenas-4856 avatar image
0 Votes"
AndresBarcenas-4856 answered ·

I am good now. Thanks. I had to do the following inside my docker config:

sed -i "s/SSH_PORT/$SSH_PORT/g" /etc/ssh/sshd_config

· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for sharing what worked for you. I am sure others in the community will find this information helpful.

0 Votes 0 ·