Docker essentials

1. Run new container
The container will stay in local containers repository after finishing and then you can start it again with “docker start containerIdOrName”. You can also add parameter –rm=true and then container will be removed after doing a command on container.
docker run --name newContainerName imageIdOrName
2. Run new container and make it working in background
docker run -di --name newContainerName imageIdOrName
3. Run new container and make it working in background and open port from container to host
docker run -di -p 8080:80 --name newContainerName imageIdOrName
4. Make stopped container working again. Also after host computer restart.
docker start containerIdOrName
5. Ssh into existing and running container
docker exec -it containerIdOrName bash

Leave a Comment.