sudo yum install -y yum-utils
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce --allowerasing
sudo systemctl enable docker && systemctl start docker
For other OS, you may refer the official documentation here https://docs.docker.com/engine/install/
sudo systemctl status docker
docker info
docker images
docker pull hello-world:latest
docker pull ubuntu:16.04
docker rmi hello-world:latest
docker run hello-world:latest
docker ps -a
docker ps
docker run -it --name ubuntu1 --hostname ubuntu1 ubuntu:16.04 /bin/bash
root@ubuntu1:/# apt update && apt install -y net-tools
root@ubuntu1:/# ifconfig
The expected output is
root@ubuntu1:/# ifconfig eth0 Link encap:Ethernet HWaddr 02:42:ac:11:00:02 inet addr:172.17.0.2 Bcast:172.17.255.255 Mask:255.255.0.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2877 errors:0 dropped:0 overruns:0 frame:0 TX packets:2336 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:19712773 (19.7 MB) TX bytes:130632 (130.6 KB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) root@ubuntu1:/#
docker ps
root@ubuntu1:/# exit
docker ps
docker start ubuntu1`
docker exec -it ubuntu1 /bin/bash
root@ubuntu1:/# exit
Exiting the second shell we launched using the above exec command will not exit the container.
docker stop ubuntu1
docker stop ubuntu2 ubuntu3
docker stop ubuntu1
docker rm ubuntu1
docker rm -f ubuntu2
docker stop $(docker ps -q)
docker rm $(docker ps -aq)
docker rm -f $(docker ps -aq)
docker restart ubuntu1
sudo yum install -y java-11-openjdk-devel
java -version
javac -version
cd ~/Downloads
wget https://mirrors.estointernet.in/apache/maven/maven-3/3.8.2/binaries/apache-maven-3.8.2-bin.tar.gz
tar xvfz apache-maven-3.8.2-bin.tar.gz
cd ~/Downloads
cd apache-maven-3.8.2
pwd
cd ~
git clone https://github.com/tektutor/jenkins-aug-2021.git
cd jenkins-aug-2021/Day1/Hello
mvn clean test
docker run -d --name artifactory --hostname artifactory -p 8081:8081 jfrog-docker-reg2.bintray.io/jfrog/artifactory-oss:4.1.0
docker psThis time c1 will be able to ping c2
If you are able to see the artifactory container running, you may access the artifactory web page at http://localhost:8081
Login Credentials
User - admin
Password - password
docker network create my-network-1
docker network create my-network-2
docker network ls
docker run -dit --name c1 --hostname c1 --network my-network-1 ubuntu:16.04 bash
docker run -dit --name c2 --hostname c2 --network my-network-2 ubuntu:16.04 bash
+-----------------------------------------+ +-----------------------------------------+ | | | | | | | | | | | | | | | | | | | | | +-----------------+ | | +-----------------+ | | | | | | | | | | | | | | | Container | | | | Container | | | | C2 | | | | C1 | | | | 172.19.0.2 | | | | 172.18.0.2 | | | | | | | +-----------------+ | | +-----------------+ | | | | | | 172.18.0.0/16 | | 172.19.0.0/16 | | my-network-1 | | my-network-2 | | | | | | | | | | | | | +-----------------------------------------+ +-----------------------------------------+
docker exec -it c1 bash
apt update && apt install -y net-tools iputils-ping
hostname -i
docker exec -it c2 bash
apt update && apt install -y net-tools iputils-ping
hostname -i
ping 172.18.0.2
As you can notice, c1 won't be able to ping c2 as they are in two different networks.
ping 172.19.0.2
As you can notice, c2 won't be able to ping c1 as they are in two different networks.
docker network connect my-network-2 c1
docker inspect c1 | grep IPA
Now c1 container will have two IPs as it is connected to two different networks.
docker exec -it c1 bash
ping 172.19.0.2
This time c1 will be able to ping c2
docker exec -it c2 bash
ping 172.19.0.3
This time c2 will be able to ping c1