iXora Custom Software Development Blog

Read | Practice | Advance

Docker for beginner

Posted by on in Blog
  • Font size: Larger Smaller
  • Hits: 1846

Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. By taking advantage of Docker’s methodologies for shipping, testing, and deploying code quickly, you can significantly reduce the delay between writing code and running it in production.


The way Docker works

Docker uses a client-server architecture. The Docker client talks to the Docker daemon, which does the heavy lifting of building, running, and distributing your Docker containers. The Docker client and daemon can run on the same system, or you can connect a Docker client to a remote Docker daemon. The Docker client and daemon communicate using a REST API, over UNIX sockets or a network interface.



Click here and create your own Docker Hub account and download your machine's operating system supported docker and install in your local machine.


Check docker version after installation

docker -v

Docker Commands

docker help

 So it will return all docker commands but some usual common docker commands given below - 

Verify your Networks

networetwork ls

Start docker containers 

docker-compose up or docker-composer up -d

Stop and remove our docker container

docker-compose down

Create our Docker image from our Dockerfile

docker build --tag my_http

Show the running containers

docker ps

Stopping a running container

docker stop CONTAINER_ID

Stop all running container

docker container stop $(docker container ls -aq)

Delete all running containers

docker container rm $(docker container ls -aq)

Delete docker image

docker rmi IMAGE_ID


Create Docker file

FROM nginx
COPY html /usr/share/nginx/html


Create Docker image from the Dockerfile

docker build --tag my_http_server 


Check the image has been created

docker images


 Run our docker image on port 8080

docker run -d -p 8080:80 --name my_http_server


 Check my docker is running?



Stop running container 

docker stop CONTAINER_ID


Find the running image ID 

docker images 


Remove the running image ID

docker rmi my_http


If removal fails force the removal

docker rmi my_http –force


Create php Docker file and image build from it

Create php Docker file

FROM php:7.2-cli
COPY ./src /usr/src/myapp
WORKDIR /usr/src/myapp
CMD [ "php", "./docker_index.php" ]

 Create our Docker image from my php Dockerfile

docker build -t run-php 

 Run my docker image which should have copied a local file called docker_index.php

docker run -it --rm --name run-app run-php

 Create php Dockerfile

FROM php:7.2-apache

 Create my docker-compose file

version: "3"
        build: .
            - "8080:80"
            - ./src:/var/www/html/
            - default

 Start my docker container from docker-compose file

docker-compose up 
docker-compose up - d    // detached mode



Note: if there is some help needed for install to create docker image then feel free to contact ixora solution. 




Rate this blog entry:


  • No comments made yet. Be the first to submit a comment

Leave your comment

Guest Thursday, 28 January 2021