Docker Tutorial
Basic Docker Commands
pull an image
docker pull {image name}:{image version}
list all docker images
docker image ls -a
create and run a docker container
docker run \
--name {container name} \
-p {host port}:{container port} \
-p {host ip}:{host port}:{container port} \
-it \
{image name}:{image version} \
{command}
specificlly, we can assign network mode of the container, such as host mode
docker run --net=host
list all docker containers
docker container ls -a
start a container
docker start {container name}
verify is there containers are running
docker ps
run a command in a running container
docker exec \
-it \
{container name} \
/bin/bash
stop a running containers
docker stop {container name}
remove a container
# docker rm [OPTIONS] CONTAINER
docker rm -f es
Docker in action
build and run an ElasticSearch image with official image
Pull an elasticsearch 7.12.1 image
docker pull elasticsearch:7.12.1
As running in development mode, create user defined network
docker network create somenetwork
Run Elasticsearch
docker run -d --name elasticsearch --net somenetwork -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.12.1
Test instrtction:
curl 127.0.0.1:9200