docker cli command

노영삼·2020년 9월 27일
0

docker

목록 보기
2/2

docker build

Build an image from a Dockerfile

docker build [OPTIONS] PATH | URL | -
OptionsDescription
--tag , -tName and optionally a tag in the ‘name:tag’ format
--file , -fName of the Dockerfile (Default is ‘PATH/Dockerfile’)

예시

docker build -t neptunes032/react-test-app -f ./frontend/Dockerfile.dev ./frontend

docker build -t neptunes032/docker-frontend ./frontend

docker commit

Create a new image from a container’s changes

docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]

docker container ls

List containers

docker container ls [OPTIONS]

docker container rm

Remove one or more containers

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

docker exec

Run a command in a running container

docker exec [OPTIONS] CONTAINER COMMAND [ARG...]

docker images

List images

docker images [OPTIONS] [REPOSITORY[:TAG]]

docker image ls

List images

docker image ls [OPTIONS] [REPOSITORY[:TAG]]

docker image rm

Remove one or more images

docker image rm [OPTIONS] IMAGE [IMAGE...]

docker inspect

Return low-level information on Docker objects

docker inspect [OPTIONS] NAME|ID [NAME|ID...]

docker logs

Fetch the logs of a container

docker logs [OPTIONS] CONTAINER

docker ps

List containers

docker ps [OPTIONS]
OptionsDescription
--all , -aShow all containers (default shows just running)
--quiet , -qOnly display numeric IDs

예시

// 모든 컨테이너 삭제
docker rm `docker ps -a -q`

docker pull

Pull an image or a repository from a registry

docker pull [OPTIONS] NAME[:TAG|@DIGEST]

docker push

Push an image or a repository to a registry

docker push [OPTIONS] NAME[:TAG]

docker run

Run a command in a new container

docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
OptionsDescription
--attach , -aAttach to STDIN, STDOUT or STDERR
--detach , -dRun container in background and print container ID
--env , -eSet environment variables
--interactive , -iKeep STDIN open even if not attached
--publish , -pPublish a container’s port(s) to the host
--volume , -vBind mount a volume

예시

docker run -e CI=true neptunes032/react-test-app npm run test
Publish or expose port (-p, --expose)

This binds port 8080 of the container to TCP port 80 on 127.0.0.1 of the host machine. You can also specify udp and sctp ports. The Docker User Guide explains in detail how to manipulate ports in Docker.

docker run -p 127.0.0.1:80:8080/tcp ubuntu bash

docker start

Start one or more stopped containers

docker start [OPTIONS] CONTAINER [CONTAINER...]

docker stop

Stop one or more running containers

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

profile
개발자가 되고싶다.

0개의 댓글