Install Docker on Linux
- We need an linux instance. We will be create a linux instance in
- AWS Cloud Refer Here
- Azure Refer Here
- Ubuntu:
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
sudo usermod -aG docker <username> #$USER
exit
# relogin
* Centos:
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
sudo usermod -aG docker <username> #$USER
exit
# relogin
sudo systemctl enable docker.service
sudo systemctl start docker.service
docker info
- The script which we have used to install docker always installs the latest stable version of docker.
- Refer Here for the shell script used
Docker Image and Container Creation Basics
- Lets see the list of the images in the newly installed docker
docker image ls
- Downloading the image from registry is called as pull
- The image name has two components
<name-of-image>:<tag>
- name of the image represents application
- tag represents the version
- If you dont pass the tag, docker will consider tag as
latest
so - if you have written image name as
httpd
==httpd:latest
- Now lets pull the
jenkins/jenkins
image
docker image pull jenkins/jenkins
* Now lets look at the tags of jenkins/jenkins Refer Here
* Every image in the registry will have unique image id.
* Two different images have the same image id imply that they are same images with different names.
* Lets create a jenkins container docker container run -d <image>:<tag>
docker container run -d jenkins/jenkins
docker container ls
* To access the application inside the docker we have to do port forwarding docker container run -d -p <hostport>:<containerport> <imageid>:<tag>
* Lets try to create an apache continer
* Overview of portforwarding
* Docker can map the container port to dynamic port on the Docker Host (Linux VM) docker container run -d -P <imageid>:<tag>