In this post, I have tried to cover most of the basic commands which are required to start working with Docker.
docker –version
Get the currently installed version of docker
docker pull
Pull images from the docker repository(hub.docker.com)
docker run
Create a container from an image
docker start
docker stop
docker ps
list the running containers
docker ps -a
show all the running and exited containers
docker images
lists all the locally stored docker images
docker rm
used to delete a stopped container
docker rmi
used to delete an image from local storage
docker exec
Used to access the running container
docker kill
Kills the container by stopping its execution immediately
docker logs
Display logs on the terminal.
docker tag
tag a docker image
Example to show the usage of the above command,
Problem statement :
Setup an Oracle database using docker.
Pull the image from the Oracle Continer Registry / docker hub.
docker pull container-registry.oracle.com/database/instantclient:latest
Tag the image: This step is not required but for better naming convention
docker tag container-registry.oracle.com/database/instantclient:latest oracle/database:12.2.0.1
Run the image:
docker run -i -t --name orcldb --network=SOANet -p 7001:7001 -v /u01/DockerVolume/SOAVolume/DB:/u01/oracle/user_projects --env-file db.env oracle/database:12.2.0.1
run - Run the image.
-i - Interactive.
-t termainal
-- name - Name the image
--network - Container connectivity.
-p - host port:container port (You can connect using the host port)
-v - map the host filesystem to the container.
--env-file - environment parameters if any (Setting up the schema name password).
oracle/database:12.2.0.1 - Image name.
db.env --
DB_SID=orcldb
DB_PDB=orcldb
DB_DOMAIN=us.oracle.com
DB_BUNDLE=basic
Once the container is up and running,
The above contaner is running on the terminal to run in a background/detached mode, start the container as,
docker start orcldb
Check the logs
docker logs -f orcldb
Inspect the container.
docker inspect orcldb
Login to the container filesystem
docker exec -it orcldb /bin/bash
Find the IP
docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' orcldb
0 Comments