Installing Docker in Ubuntu 2004 on VirtualBox
![](https://devops.egyan.space/wp-content/uploads/2021/01/image-8.png)
To try out Docker on Local PC either we can get the Docker installed from the docker official website, or have it installed under a Linux VM to simulate a more Enterprise type setup on your Local PC.
Prerequisites:
- Win 10
- VirtualBox Installed
- Linux VM ubuntu 2004 configured in the VirtualBox.
1 – Install Docker
sudo apt install docker.io
2 – Install Docker dependencies
sudo snap install docker
![](https://devops.egyan.space/wp-content/uploads/2021/01/image.png)
3 – Thats it we are done here & you are good to explore docker now on your VM
sudo docker --version
![](https://devops.egyan.space/wp-content/uploads/2021/01/image-1.png)
Checking All docker packages & which are available in the repo & which are installed on our VM
![](https://devops.egyan.space/wp-content/uploads/2021/01/image-2.png)
Create & run an apache Hello world image in Docker
#In Current Dir create the HTML static files which you will push in Apache Webserver's htdocs
mkdir public_html ; cd public_html ; vi HelloWorld.html
#Put any content you wish in this file, save it with :wq in vim command mode.
#Now go back to original directory & create Dockerfile:
cd .. ; vi Dockerfile
#copy & paste below 2 lines in Dockerfile.
FROM httpd:2.4
COPY ./public_html/ /usr/local/apache2/htdocs
#Now run below command to create the docker image
sudo docker build -t my-apache2 .
![](https://devops.egyan.space/wp-content/uploads/2021/01/image-5.png)
![](https://devops.egyan.space/wp-content/uploads/2021/01/image-4.png)
So till now the image is created, now we need to run it inside a container, in that container apache server will be running on Port 80 & will be accessible to us on port 8080 externally due to mapping , you can map it to any port of your choice.
![](https://devops.egyan.space/wp-content/uploads/2021/01/image-6.png)
sudo docker run -dit --name apacheVB -p 8080:80 my-apache2
#-dit means , Detached(so that it runs in the background), Interactive (You can switch to it & run commands) T(with a TTY So you can see input & output
# -p = Here we expose port 8080 externally which you can access from browser, it is mapped to port 80 which is apache port & running inside the container
#Check the container process details :
sudo docker ps
![](https://devops.egyan.space/wp-content/uploads/2021/01/image-7-1024x51.png)
Now test the webpage which is hosted in the apache, Open below URL
http://localhost:8080/HelloWorld.html
So today, we have setup Docker in Ubuntu 2004 on Virtualbox running on Windows 10.
Let us know if you faced any issues or errors while trying same.