프로그램 사용/docker2019. 7. 15. 15:51

 

Dockerfile

COPY .(host) .(container)

CMD 는 ENTRYPOINT의 일부(둘다 지정시)


CMD
The CMD instruction has three forms:
CMD ["executable","param1","param2"] (exec form, this is the preferred form)
CMD ["param1","param2"] (as default parameters to ENTRYPOINT)
CMD command param1 param2 (shell form) <<<<< SHELL FORM

 


docker run -it ubuntu bash
는 cmd를 엎어 씀
entrypoint는 덮어 쓸수 없음(그렇기에 entry point없이 cmd만으로 된것으로 확인할수 있음)

        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "/bin/bash"
            ],
            "ArgsEscaped": true,
            "Image": "sha256:ae950a0376fe6c4d08fa7ff395f50f4a909e26e9f2d865d8641cda024161c6ee",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": null
        },

----

docker run help
      --entrypoint string              Overwrite the default ENTRYPOINT of the image

 


[링크 : https://docs.docker.com/engine/reference/builder/#understand-how-cmd-and-entrypoint-interact]

 

 

복수개의 Run

FROM golang:1.11-alpine AS build

# Install tools required for project
# Run `docker build --no-cache .` to update dependencies
RUN apk add --no-cache git
RUN go get github.com/golang/dep/cmd/dep

# List project dependencies with Gopkg.toml and Gopkg.lock
# These layers are only re-built when Gopkg files are updated
COPY Gopkg.lock Gopkg.toml /go/src/project/
WORKDIR /go/src/project/
# Install library dependencies
RUN dep ensure -vendor-only

# Copy the entire project and build it
# This layer is rebuilt when a file changes in the project directory
COPY . /go/src/project/
RUN go build -o /bin/project

# This results in a single layer image
FROM scratch
COPY --from=build /bin/project /bin/project
ENTRYPOINT ["/bin/project"]
CMD ["--help"]


[링크 : https://docs.docker.com/develop/develop-images/dockerfile_best-practices/]

'프로그램 사용 > docker' 카테고리의 다른 글

도커 cpu 갯수 제한  (0) 2024.03.22
docker snap 버전 문제  (0) 2022.10.12
docker remote  (0) 2019.07.15
UTS name space  (0) 2019.07.15
LXC LXD  (0) 2019.07.15
Posted by 구차니