To Install Docker on Mac, follow the instructions at below link.
https://docs.docker.com/docker-for-mac/install/
To install Docker on Windows, follow the intructions at below link.
https://docs.docker.com/docker-for-windows/install/
To install Docker on Linux, follow the instructions at below link.
Centos : https://docs.docker.com/engine/install/centos/
Ubantu : https://docs.docker.com/engine/install/ubuntu/
Debian : https://docs.docker.com/engine/install/debian/
Fedora : https://docs.docker.com/engine/install/fedora/
To access Docker Hub, Please visit below url
- To check Docker Version :
docker --version
- To Start the Docker on Linux :
docker service docker start
- To Stop the Docker on Linux :
docker service docker stop
- To check the running containers :
docker ps
- To check all the containers (running and terminated) :
docker ps -a
- To check docker images :
docker image
- To remove an docker image :
docker rmi $image_id
- To build a docker image from Dockerfile :
docker build
docker build -t $imageName:tagName
docker build -t my-test-app:1.0.0
- To Login to Docker Hub Repository :
docker login
- To Push an image to DockerHub Repository :
docker push $dockerHubId/$imageId:$tagName
docker push shubhamkushwah123/my-test-app:1.0.0
- To Pull an image from DockerHub Repository :
docker pull $dockerHubId/$imageId:$tagName
docker pull shubhamkushwah123/my-test-app:1.0.0
- To Run an Docker image :
docker run -p $entryPort:$PortToBeMapped -d $dockerId/$imageId:$tagName
docker run -p 8888:8080 -d shubhamkushwah123/my-test-app:1.0.0
- FROM : It tells docker from which base image, you want to create your image from. Usage :
FROM <image>
FROM <image>:<tag>
- RUN : This command is used to run the instructions against the image. Usage :
RUN <command>
- CMD : CMD is used to provide default arguments for the ENTRYPOINT instruction, both the CMD and ENTRYPOINT instructions should be specified with the JSON array format. Note : Please note that there can only be one CMD in a Dockerfile. Usage :
CMD <command> <param1> <param2> (shell form)
- MAINTAINER : It is used to specify the maintainer of the Dockerfile. In our case, we just specify the email id. Usage :
MAINTAINER <name>
- ADD : Adds new files, directories, or remote file URLs from and adds them to the filesystem of the image at the path . Usage :
ADD <src> <dest>
- ENTRYPOINT : Allows you to configure a container that will run as an executable. Usage :
ENTRYPOINT <command> <param1> <param2> (shell form)
- ENV : The ENV instruction sets the environment variable to the value . Usage :
ENV <key> <value>
- EXPOSE : It Informs Docker that the container listens on the specified network port(s) at runtime. Usage :
EXPOSE <port> [<port> ...]
- USER : The USER instruction sets the user name or UID to use when running the image and for any RUN, CMD and ENTRYPOINT instructions that follow it in the Dockerfile. Usage :
USER <username | UID>
- VOL : Creates a mount point with the specified name and marks it as holding externally mounted volumes from native host or other containers. Usage :
VOLUME <path>
- COPY : Copies new files or directories from and adds them to the filesystem of the image at the path . Usage :
COPY <src> [<src> ...] <dest>
- WORKDIR : Sets the working directory for any RUN, CMD, ENTRYPOINT, COPY, and ADD instructions that follow it. Usage :
WORKDIR </path/to/workdir>
- ARG : Defines a variable that users can pass at build-time to the builder with the docker build command. Usage :
ARG <name>[=<default value>]FROM openjdk:8-jdk-alpine
VOLUME /tmp
EXPOSE 8888
ARG JAR_FILE=/target/*.jar
COPY ${JAR_FILE} app.jar
RUN echo "Creation of your docker image is in progress, please hold on for a moment"
ENTRYPOINT ["java", "-jar", "app.jar"]
MAINTAINER "shubhamkushwah123@gmail.com"