Docker Commands
1.docker –version
This command is used to get the currently installed version of docker
2.docker pull
docker pull - This command is used to pull images from the docker repository(hub.docker.com)
3.docker run
Usage: docker run -it -d - This command is used to create a container from an image
4.docker ps
This command is used to list the running containers
5.docker ps -a
This command is used to show all the running and exited containers
6.docker exec
docker exec -it bash - This command is used to access the running container
7.docker stop
docker stop - This command stops a running container
8.docker kill
docker kill - This command kills the container by stopping its execution immediately. The difference between ‘docker kill’ and ‘docker stop’ is that ‘docker stop’ gives the container time to shutdown gracefully, in situations when it is taking too much time for getting the container to stop, one can opt to kill it
9.docker commit
docker commit - This command creates a new image of an edited container on the local system
10.docker login
This command is used to login to the docker hub repository
11.docker push
docker push - This command is used to push an image to the docker hub repository
12.docker images
This command lists all the locally stored docker images
13.docker rm
docker rm - This command is used to delete a stopped container
14.docker rmi
docker rmi - This command is used to delete an image from local storage
15.docker build
docker build - This command is used to build an image from a specified docker file
Docker Php Application Example
A Dockerfile is a text document that contains commands that are used to assemble an image
1.Create a directory
mkdir php-docker-app
2.Create a Php File
<?php
echo ?Hello, Php?;
?>
3.Create a DockerFile
FROM php:7.0-apache
COPY . /var/www/php
4.Create Docker Image
docker build -t php-docker-app .
Which will create the docker image
5.Run the Docker image
docker run php-docker-app
We can see that our docker image is running and output is shown to the browser. This image is running on the local host.
Top comments (0)