Thursday, March 18, 2021

Docker Advance

 More detail in docker container command usage below:

1) Using environment to change the process argument 

$ docker run -e YOUR_ENV_FOO=YOUR_NEW_ARG --name YOUR_PROCESS_NAME YOUR_IMAGES


2) Building your own images with Dockerfile

$ docker build -t YOUR_IMAGES_TAG YOUR_FILE_PATH


3) Dockerfile example 

File_layout: Docker execute command and your process command

FROM - from any image public or local 

RUN - running a command from your image

COPY - copy a scipt to your image path

EXPOSE - expose a port for the web connection if your app is a web

ENTRYPOINT - the docker running process entry point , can be a modified environment entry point in running a image process

Ubuntu image Dockerfile below:

After docker run ubuntu image will calling bash command, so the docker run will execute ENTRYPOINT + CMD in Dockerfile

4) Running docker process in background detach mode

$ docker run -d YOUR_PROCESS


5) Linking your process with a database OR process related

$ docker run --link HOST_MAPED_NAME:DB_MAPPED_NAME -p HOST_MAPPED_PORT:CONTAINER_MAPPED_PORT wordpress


6) Create a docker compose yaml for running a batch process


7) Running a docker compose yaml under the yaml folder

$ docker-compose up 


8) Mapping a storage to link the container data to avoid the data lost with the process stopped

$ docker run -v HOST_DATA_PATH:CONTAINER_DATA_PATH 

Mapping back your data with the previous process

9) Listing current docker network

$ docker network ls


10) Inspect the detail of the network 

$ docker network inspect YOUR_CURRENT_NETWORK


11) Create a new subnet in the same network 

$ docker network create --driver YOUR_NETWORK --subnet YOUR_NEW_SUBNET --gateway YOUR_NEW_GATEWAY

Creating a new network , and run a process in a new network with the tag name




No comments:

Post a Comment