Docker Internals
- Refer Here for Docekr internals
Docker Container (Contd..)
- Execute the following command
docker container run --help
docker container --help
- To remove all the containers
docker container rm -f $(docker container ls -a -q)
Portforwading
- To access the app on the container we use port forwarding
- To acheive this in command line
- Assign dynamic port on host.
docker container run -P <image> docker container run -P -d jenkins docker container ls
- Assign a specific port on host
docker container run -p <hostport>:<containerport> <image> docker container run -p 80:8080 -d jenkins docker container ls
Docker container modes
- Attached :
- Container runs in the foreground
- Default mode of docker
- Example:
docker container run -P jenkins
- Detached
- Docker container runs in the background
- add -d to container run to set this mode
- Example:
docker container run -P -d jenkins
- Interactive
- In this mode we can interact with docker using terminal (/bin/bash, /bin/sh)
- add -it to container run to set this mode
- Example
docker container run -it -P jenkins /bin/bash
Experiment with docker command line
- Execute
docker container --help