Prerequisites
- Docker installed on the System
Introduction
Developing apps today requires so much more than writing code. Multiple languages, frameworks, architectures, and discontinuous interfaces between tools for each lifecycle stage creates enormous complexity. Docker simplifies and accelerates your workflow, while giving developers the freedom to innovate with their choice of tools, application stacks, and deployment environments for each project
-- Docker
Commands
0. Check Docker version
docker --version
1. To search for an image on the docker-hub registry
docker search <image_name>:<tag>
2. To pull an image from the docker-hub registry
docker pull <image_name>:<tag>
3. Running a docker container
docker run --name <name> -d -p <host_OS_port>:<application_port> <image_name>:<tag>
- -d : to run the container in detached mode
- --name : to give a customized name to the running container
- -p : to define the port on the Host OS in order to access the container port
4. Seeing the running containers
docker ps
Or
docker container ls
Using docker ps -a we can get the information about containers whether they are running or stopped
5. Checking the images on the local machine
docker image ls
6. Stopping running containers
docker stop <container_name OR container_ID>
7. Starting stopped containers
docker stop <container_name OR container_ID>
8. Removing stopped containers
docker stop <container_name OR container_ID>
9. Running commands inside the containers
docker exec -it <container_name OR container_ID> bash
- -i : to run an interactive shell
- -t : to activate pseudo-tty
10. Get low-level information about containers
docker inspect <container_name OR container_ID> bash
Congratulations on getting started with Docker. Now go ahead and build and deploy on Docker
Useful Link: Docker Guides