Acesess The Container Shell
1. Changing file content : Now we are going to use the container shell to change the content of the user_env.txt file inside the docker container file system. Note that the user_env.txt file in you local machine will be different then the docker container user_env.txt file as each docker container has its own file system. To change the content of the file we first need to get into the container shell using the below command
docker exec -it container_id /bin/bash
The above commands will get you inside the docker container shell, container_id is the id if the container which we got using the docker ps command. Now you can execute commands using the shell. We are going to change the content of user_env.txt using the below command
sh -c ‘echo “GFG” > /user_env.txt’
The above command changed the content of the ser_env.txt file inside the docker container, now when you reload the below url it should display GFG.
Docker – Containers & Shells
Docker is a set of platforms as a service (PaaS) products that use Operating system-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries, and configuration files; they can communicate with each other through well-defined channels. All containers are run by a single operating system kernel and therefore use fewer resources than a virtual machine.