Here is a short list of Docker commands for operations such as start, stop, and delete:
Operation |
Command |
Run a container from an image |
The syntax is as follows: docker run –name <container_name> <options> <base_image> <command_to_run> For example, to run a container from an Ubuntu image, open a Terminal and execute the bash shell with the following command: docker run -name my-ubuntu -it ubuntu bash |
Create an image from a Dockerfile |
The syntax is as follows: docker build <options> <folder_of_dockerfile> For example, to create my_image from a Dockerfile in the current folder, run the following Docker command: docker build -t image_name |
List currently running containers |
docker ps |
List all containers, including stopped containers |
docker ps -a |
Start (a stopped) container |
The syntax is as follows: docker start -i <container> The -i option keeps stdin (standard input) open and allows you to run commands in the container. To identify the container, you can either use the container name or ID. |
Remove a container |
docker rm <container> |
Execute command in running container |
The syntax is as follows: docker exec <options> <container> <command> For example, to open a bash shell in a running container called my_container, execute the following command: docker exec –it my_container bash |
Listing all images |
docker images |
Deleting images |
Image IDs are space separated in this command: docker rmi <image_ids>
|
Get information about running container |
docker inspect <container> |
That was a short introduction to Docker. There are many more details of Docker that are out of the scope of this book. Please refer to the links provided and also the Docker website (https://www.docker.com/) for more information. We will now focus on Eclipse tooling for Docker and deploying microservices in Docker containers.