When you start a docker container you can specify environment settings like what port to listen on https and http, see example below:
docker run -p 5000:5000 -p 5001:5000 -e ASPNETCORE_HTTPS_PORT=https://+:5001
-e ASPNETCORE_URLS=http://+:5000 --name aspnetcore_sample aspnetapp
Docker adding all new containers default to a bridge network but on the default bridge network you only can communicate between containers with ip-address, to communicate with containers name instead you need to define your own bridge network:
docker network create --driver bridge network01 --subnet=10.11.0.0/16
Then when you run the container add –network network01 to let the container connect to the new network and you can then communicate between containers by using the name you set on the container instead of communicate by ip-address that changes after a reboot and other things.
If you not specify any network on a container Docker seems to use a bridged wish gives it a own virtual ip-address in a virtual network where all containers are in.
You can get the ip-address by using this command on the docker server:
docker inspect <container_id> | grep IPAddress
I have started to learn Docker and a nice one liner to have saved somewhere is this one that setting up a docker container with MS SQL server and a SA password + setting up a docker volume to hold the data for MS SQL Server.
docker run -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=<YourStrong@Passw0rd>' -p 1433:1433 -v sqlvolume:/var/opt/mssql --name sql1 --hostname sql1 -d mcr.microsoft.com/mssql/server:2019-latest
Reference information can be found on https://learn.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker