Environment Variables
If suppose the developer mentioned some –env (Environmental variables) in the source code by which we can connect to the database server, for example, Username and password then while creating the container we set the username and password as shown in the below command.
docker run -d --name <name> -e USERNAME=<***> -e PASSWORD=<***> --network <****>
We can set the above-mentioned env variables to the database container by using the following command.
docker run -d -p <port> --name <name> -e HOSTNAME=<***> -e USERNAME=<***> -e PASSWORD=<***> --network <***>
Docker – Container Linking
Docker is a set of platforms as a service (PaaS) products that use the Operating system level visualization to deliver software in packages called containers.There are times during the development of our application when we need two containers to be able to communicate with each other. It might be possible that the services of both containers are dependent on each other. This can be done with the help of Container Linking.
Previously the containers were used by using the “–link” flag but that has now become deprecated and is considered a legacy command.