[Docker] commands

llunaB·2022년 2월 13일

deploy

목록 보기
3/7

docker build

Build a docker image

Build an image from a Dockerfile

  • t : 태그 자동 지정
  • -rm : Remove intermediate containers after a successful build
  • --tag , -t : Name and optionally a tag in the 'name:tag' format
docker build -t <username>/<respository> .

upload docker image on docker hub

docker push <username>/<respository> 

docker run

Docker runs processes in isolated containers. A container is a process which runs on a host.

The docker run command must specify an IMAGE to derive the container from.

With the docker run [OPTIONS] an operator can add to or override the image defaults set by a developer. And, additionally, operators can override nearly all the defaults set by the Docker runtime itself.

docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]

Option : Detached (-d)

  • To start a container in detached mode, you use -d=true or just -d option.
  • By design, containers started in detached mode exit when the root process used to run the container exits, unless you also specify the --rm option.
  • If you use -d with --rm, the container is removed when it exits or when the daemon exits, whichever happens first.
docker run -d -p 80:80 my_image

Option : Container identification (--name)

docker run --name my-redis -d redis

OptionL: Clean up (--rm)

Docker to automatically clean up the container and remove the file system when the container exits, you can add the --rm flag:

--rm=false: Automatically remove the container when it exits

docker images

도커 이미지 확인

docker images

도커 이미지 삭제 rmi

docker rmi [OPTIONS] IMAGE

docker container

run docker image on a container 도커 이미지 실행

  • -rm
  • -d
  • -p
docker run --rm -d -p 8080:8080 --name <container-name> <username>/<repository>

view a list of all containers 모든 컨테이너 검색

docker ps -a

docker container logs 유지하기

  • --follow
docker container logs --follow CONTAINER

docker container stop 컨테이너 중지

Stop one or more running containers

docker container stop [OPTIONS] CONTAINER [CONTAINER...]

docker container rm 강제 컨테이너 삭제

Remove one or more containers
---force, -f

docker container rm [OPTIONS] CONTAINER [CONTAINER...]

docker rm

Remove a container

This removes the container referenced under the link /redis.

docker rm /redis

Remove all stopped containers

docker ps --filter status=exited -q | xargs docker rm

Force-remove a running container

This command force-removes a running container.

docker rm --force redis

delete docker image

docker remove <imagename>
profile
안녕하세요. 성장하는 주니어 개발자입니다. :-)

0개의 댓글