Docker commands - yunkon-kim/test-on-github-actions GitHub Wiki

Docker๋ฅผ ์“ฐ๋‹ค๋ณด๋ฉด ํ•„์š”ํ•˜์ง€๋งŒ ์ƒ๊ฐ์ด ๋‚˜์ง€์•Š์•„ ๊ฒ€์ƒ‰ํ•˜๊ฒŒ ๋˜๋Š” Command ์ž…๋‹ˆ๋‹ค. ์ž์ฃผ ์‚ฌ์šฉํ•˜๋Š” ๋‹ค๋ฅธ Command๋„ ์—ฌ๊ธฐ์— ์—…๋ฐ์ดํŠธ ํ•ด์ฃผ์„ธ์š”. ๐Ÿ˜„

Daemon์œผ๋กœ ์‹คํ–‰๋œ Container ์ ‘์†

docker exec -it [CONTAINER ID] /bin/bash

Host, Container ๊ฐ„ ํŒŒ์ผ ๋ณต์‚ฌ

Host to container

docker cp [HOST_PATH] [CONTAINER_NAME or CONTAINER_ID]:[CONTAINER_PATH]

Container to host

docker cp [CONTAINER_NAME or CONTAINER_ID]:[CONTAINER_PATH] [HOST_PATH] 

Use volumes

According to Docker docs, -v or --volume: Consists of three fields, separated by colon characters (:). The fields must be in the correct order, and the meaning of each field is not immediately obvious.

  • In the case of named volumes, the first field is the name of the volume, and is unique on a given host machine. For anonymous volumes, the first field is omitted.
  • The second field is the path where the file or directory is mounted in the container.
  • The third field is optional, and is a comma-separated list of options, such as ro. These options are discussed below.
docker run -d --name [CONTAINER_NAME] -v [HOST_PATH]:[CONTAINER_PATH] [IMAGE_NAME]

Docker hub์— Container ์—…๋กœ๋“œํ•˜๊ธฐ