I want to learn docker and how i can manage the containers inside the docker environment such that they can be used as dev environments.
I am a complete beginner while using Docker. I have a remote machine running ubuntu. I connect to that using ssh from my windows machine to use it as a dev environment. What i want to do is I want to create two other containers inside that remote machine, one of kali linux and another of centos9. I want to be able to use those containers as dev environments seperately. Just like i have connected to the remote machine using ssh i want those two containers to be accessible through ssh from my vscode remote explorer extension.(similar to making an ssh connection).
My thought on how one can do this is by following these steps:
- Install docker in the remote ubuntu machine by connecting through ssh to that machine from my windows machine.
- After this pull the kali and centos images from docker hub.(the os pulled may be any)
- Start the containers with this command
docker run -itd --network=host -p 2222:localhost:22 --name kali_container kalilinux/kali-rolling
docker run -itd --network=host -p 2223:localhost:22 --name centos_container centos
and allow those ports 2222 and 2223 to be mapped to any two ports in the host machine like 1020,1021,1022 because i still have to access the ubuntu container that is running which works as my host machine(port 1020) and 1021 and 1022 ports are for the two new containers inside those containers.
This is a thought and i want to try this out. I want help in this and a complete procedure on how i can do this. My main purpose is to create a versioning system based on this such that the host machine will keep images of the two containers running at certain interval of time and if something breaks in the two containers when i am using them as dev environments, i can rollback to previous images.
Please help me with this.