Go to hub.docker.com
search for ubuntu, centos, mysql
How to create custom image
Custom file --> is your --> own image
Dickerfile -> Docker scripting language
Traditionally just to use a web server, we used to use physical machine, physical network, but these days we have a host a machine, we have a VM, and inside VM, we can run docker.
1. Install Redhat 8 on your system.
# docker ps
# docker ps -a
# yum install python36
# python3
# cat Dockerfile
FROM centos
RUN yum install python36 -y
# docker images
# docker images | grep exp
# docker build -t expanor:v1 /ws/
Now, your image is ready. Based on this image, you can launch 100s of other os instances
# docker run -it ==nme os2 nexpanor:v1
# docker ps
# python3
# vi Dockerfile
FROM centos
RUN yum install python36 -y
# docker rm -f $(docker ps -a -9) # terminates all docker instalnces
# docker run -it --name os1 centos
Create a file on your VM
# yum install https -y
# vi index.html
Life is beautiful !!!
# docker run -it --name OS1 centos # Create an OS docker instance OS1
# docker cp index.html os1:/var/www/html
On your docker instance, try to start the webserver
You will get error
Now, go ahead and start wen server on your VM.
# systemctl start httpd
# systemctl status htpd
look at the httpd service file at /usr/lib/systemd/system/httpd.service
Now, cat that file and look under
execStart
ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND
now remove $OPTIONS and manually run the command below on docker
# /usr/sbin/httpd -DFOREGROUND
To find the IP address of docker, you can use inspect option
# docker inspect OS1
# docker rm -r os1
Review
# mkdir /workfile; cd /workfile
# cat >>index.html
Welcome to my page !!!
# cat Dockerfile
FROM centos
RUN yum install httpd -y
# docker images
# docker build -t expanor:v1 /ws/
Now, your image is ready. Based on this image, you can create hundreds of other docker instances.
# docker imags | grep exp - to see your image you just created.
# docker ps
# docker run -it --name os2 expanor:v1
# docker ps
# cat Dockerfile
FROM centos
RUN yum install httpd -y
RUN yum install python36 -y
CMD python3
# docker build -it expanor:v2 /ws/
when you run above command, you will be at python prompt. just type exot() to close the doccer sesssion.
# docker ps
# docker rm -f $(docker ps = a =9) # terminate att docker session
# docker run -it --name OS1 centos
search for ubuntu, centos, mysql
How to create custom image
Custom file --> is your --> own image
Dickerfile -> Docker scripting language
Traditionally just to use a web server, we used to use physical machine, physical network, but these days we have a host a machine, we have a VM, and inside VM, we can run docker.
1. Install Redhat 8 on your system.
# docker ps
# docker ps -a
# yum install python36
# python3
# cat Dockerfile
FROM centos
RUN yum install python36 -y
# docker images
# docker images | grep exp
# docker build -t expanor:v1 /ws/
Now, your image is ready. Based on this image, you can launch 100s of other os instances
# docker run -it ==nme os2 nexpanor:v1
# docker ps
# python3
# vi Dockerfile
FROM centos
RUN yum install python36 -y
# docker rm -f $(docker ps -a -9) # terminates all docker instalnces
# docker run -it --name os1 centos
Create a file on your VM
# yum install https -y
# vi index.html
Life is beautiful !!!
# docker run -it --name OS1 centos # Create an OS docker instance OS1
# docker cp index.html os1:/var/www/html
On your docker instance, try to start the webserver
You will get error
Now, go ahead and start wen server on your VM.
# systemctl start httpd
# systemctl status htpd
look at the httpd service file at /usr/lib/systemd/system/httpd.service
Now, cat that file and look under
execStart
ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND
now remove $OPTIONS and manually run the command below on docker
# /usr/sbin/httpd -DFOREGROUND
To find the IP address of docker, you can use inspect option
# docker inspect OS1
# docker rm -r os1
Review
# mkdir /workfile; cd /workfile
# cat >>index.html
Welcome to my page !!!
# cat Dockerfile
FROM centos
RUN yum install httpd -y
# docker images
# docker build -t expanor:v1 /ws/
Now, your image is ready. Based on this image, you can create hundreds of other docker instances.
# docker imags | grep exp - to see your image you just created.
# docker ps
# docker run -it --name os2 expanor:v1
# docker ps
# cat Dockerfile
FROM centos
RUN yum install httpd -y
RUN yum install python36 -y
CMD python3
# docker build -it expanor:v2 /ws/
when you run above command, you will be at python prompt. just type exot() to close the doccer sesssion.
# docker ps
# docker rm -f $(docker ps = a =9) # terminate att docker session
# docker run -it --name OS1 centos
No comments:
Post a Comment