Simple apache service on top of Docker - Basic commands - Example

We can get base images form the docker hub repository

Tip: you can make customer images in docker hub (you will have to log in to docker-hub and then push the image you customised)


We can download the docker image from the centre repository. Let’s download a ubuntu latest image from the repository.


docker pull ubuntu


Then, you can see the image by typing in terminal,


docker images ubuntu


After, If you want to run the docker image you can execute following command in the terminal


docker container run -it web-application -p 80:80 -d ubuntu


Here, the Ubuntu image is started with assigned name “web-application” and port forward is done with assigning 80:80 as host port : container port


Then you will see the container id under when it is started.


After, let’s install a apache service in the ubuntu container we created. To log in to the container, type


docker exec -it web-application bash


And then you will be in the container.Now we are going to install apache 


apt install apache2


Then the apache will be installed on top of the docker container


Now start  apache2 service and in browser type the host IP address and the port we assigned.

You will see the apache default page loaded.


If you want to remove docker container, then use,


docker rm -f web-application


Source :

https://www.linkedin.com/events/kubernetes-freetechnicalworksho6807993779836985344/

Comments

Popular posts from this blog

How to push a file into a docker container

Docker - Begginer 1

Project(on going) - IPv6 Fragmentation