Environmental Variables and Port Mapping for running container

Question : 1
The Environmental Variable MYSQL_ROOT_PASSWORD on the inspect Image was not found however, able to set the environmental variable on the mysql container. How is this possible as there is no defined variable can we define it on the container image?? I mean edit the image?

Question 2
Can set the port mapping on the running container if yes, how??

Hi @KiranS

  • For the first question:

We define environment variables to be made use by the mysql container.

Please see the reference : https://hub.docker.com/_/mysql


In this example we are setting the MYSQL root password which is expected when the DB starts up.

See the above link for all environment option.

These are specific to the containers and not specific to Docker in general.

  • For the second question:
    You can change the port mapping by directly editing the hostconfig.json file at /var/lib/docker/containers/[hash_of_the_container]/hostconfig.json
    Hope this helps.