Docker Desktop Basics

Docker Desktop Basics

Docker Desktop: Docker Desktop is secure, out-of-the-box containerization software offering developers and teams a robust, hybrid toolkit to build, share, and run applications anywhere. Dockers are: quick to setup, simple to maintain, secure from the start and easy to scale.

  • Open the Docker Desktop App or install it from https://www.docker.com/products/docker-desktop/
  • There are two things that you need to take it into consideration: Images and Containers
  • Images: A Docker image is a file used to execute code in a Docker container. Docker images act as a set of instructions to build a Docker cotainer, such as a template. Docker images also act as the starting point when using Docker. An image is comparable to a snapshot in virtual machine (VM) environments.
  • Containers: A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another. A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings. [ Images running are store in container ]

Steps to run a simple webpage using nginx

Step 1: Create a folder named Docker and a new file called Dockerfile. [ Don’t make the .txt file]

Step 2: Open the file with Pycharm Community or download it to install at https://www.jetbrains.com/pycharm/download/

Step 3: Open it in project mode instead of light editor.

Step 4: Create a new file named index.html and write some HTML sample code you want to display.

Step 5: Open the terminal on the left bottom of the Pycharm IDE.

Step 6: Open the docker desktop app too.

Step 7: Write down the following code from https://hub.docker.com/_/nginx

docker run --name some-nginx -v /some/content:/usr/share/nginx/html:ro -p 8081:80 -d nginx

# The /some/content should be replaced with the path of index.html created in step 4
# In my case file name: C:\Users\abliv\Desktop\day5_Docker\index.html

docker run --name some-nginx -v C:\Users\abliv\Desktop\day5_Docker\:/usr/share/nginx/html:ro -p 8081:80 -d nginx

Now to view the page go to the browser and type:

localhost:8081