100% found this document useful (1 vote)
15 views

Docker (Containerization) Presentation Lab 1 and Lab 2 (1)

Uploaded by

San Lin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
15 views

Docker (Containerization) Presentation Lab 1 and Lab 2 (1)

Uploaded by

San Lin
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

4th Year CS Cloud Computing (for Container presentation) U Yin Ko Latt

Container Docker command


To manage Docker containers, you can use the docker start and docker stop commands. These
commands allow you to start and stop containers that have already been created.
(1) Run a Container: First, create and run a container. For example:
docker run -it --name [container] ubuntu bash
(2) Exit the Container: Exit the container to stop it.
Exit
(3) Start the Container: Start the stopped container.
docker start [container]
(4) Attach to the Container: To reattach to the container's bash shell, you can use docker attach.
docker attach [container]
(5) Stop the Container: Stop the running container.
docker stop [Container]

How to use docker network


Docker Network command
1. docker network create
Create a new network named my_network using the default bridge driver.
docker network create my_network

2. docker network connect


Connect a container named my_container to the network my_network.
docker network connect my_network my_container

3. docker network disconnect


Disconnect a container named my_container from the network my_network.
docker network disconnect my_network my_container

4. docker network inspect


Inspect detailed information about the network my_network.
docker network inspect my_network

5. docker network ls
List all networks.
docker network ls

6.Remove the Network


Use the following command to remove a network by its name or ID:
Replace <network_name_or_id> with the name or ID of the network you want to delete.
Page 1 of 10
4th Year CS Cloud Computing (for Container presentation) U Yin Ko Latt

docker network rm <network_name_or_id>

7. docker network prune


Remove all unused networks.
docker network prune –force
Lab 1:
Installation for wordpress container and mySQL container
mySQL container installation
docker run --name mysql-container --network wordpress-network -e
MYSQL_ROOT_PASSWORD=rootpassword -e MYSQL_DATABASE=wordpress -e
MYSQL_USER=wordpressuser -e MYSQL_PASSWORD=wordpresspassword -d mysql:5.7

Wordpress Container Installation


docker run --name wordpress-container --network wordpress-network -p 8000:80 -e
WORDPRESS_DB_HOST=mysql-container:3306 -e WORDPRESS_DB_NAME=wordpress -e
WORDPRESS_DB_USER=wordpressuser -e WORDPRESS_DB_PASSWORD=wordpresspassword -d
wordpress:latest

Page 2 of 10
4th Year CS Cloud Computing (for Container presentation) U Yin Ko Latt

Page 3 of 10
4th Year CS Cloud Computing (for Container presentation) U Yin Ko Latt

Lab 2: Ubuntu SSH server and ubuntu SSH client docker containers installation

Step 1: pull the ubuntu image


To pull Ubuntu Image
docker pull ubuntu

To check image is pulled or not


docker image ls

Step 2: Create First Docker Container


Now create first Ubuntu container by,
docker run -it --name sshserver-container ubuntu
Notes: (-it means run container in interactive mode, image name = ubuntu and container name =
sshserver-container)

Step 3: Inside first container (sshserver-container) commands, update all packages

Page 4 of 10
4th Year CS Cloud Computing (for Container presentation) U Yin Ko Latt

Step 3: install SSH-Server


apt-get install openssh-server

Choose time zone

Page 5 of 10
4th Year CS Cloud Computing (for Container presentation) U Yin Ko Latt

Step 4: install nano editor


apt-get install nano

Step 5: configure ssh_config file in first container (sshserver-container)


nano /etc/ssh/sshd_config

Note: In sshd_config, uncomment line “permitRootLogin prohobit-password ” line and change to


“permitRootLogin yes ”

Page 6 of 10
4th Year CS Cloud Computing (for Container presentation) U Yin Ko Latt

Step 6: Checking SSH service start


service --status-all

Step 7: Starting SSH service

Step 8: Go outside the sshserver-container


Exit

Create Second ssh-client Docker Container


Now create second Ubuntu container
Step 1: docker run -it --name sshclient-container ubuntu

Step 2: update sshclient-container ubuntu


apt-get update
Notes: apt-get update command retrieves information about the latest versions of packages and their
dependencies from the repositories configured on your system.

Page 7 of 10
4th Year CS Cloud Computing (for Container presentation) U Yin Ko Latt

Step 3: To install SSH Client on sshclient-container docker


apt-get install openssh-client

Step 4: Go outside the sshclient-container


Exit

Step 5: go to sshserver-container and set new password for root


docker exec -it sshserver-container bash

Page 8 of 10
4th Year CS Cloud Computing (for Container presentation) U Yin Ko Latt

Step 6: exit from sshserver-container,

Step 7: To check the IP Address of the sshserver-container


docker inspect sshserver-container

Step 8: Go to the sshclient-container,


docker exec -it sshclient-container bash

Step 8: Connect to sshserver-container (172.17.0.3)


Note: sshserver-container (SSH service enabled)
ssh [email protected]

Page 9 of 10
4th Year CS Cloud Computing (for Container presentation) U Yin Ko Latt

Lab 2 finished.

Wow …Yor are Awesome

Page 10 of 10

You might also like