OSDN Git Service

Regular updates
[twpd/master.git] / dockerfile.md
1 ---
2 title: Dockerfile
3 category: Devops
4 layout: 2017/sheet
5 prism_languages: [docker]
6 updated: 2019-10-20
7 ---
8
9 ## Reference
10 {: .-three-column}
11
12 ### Inheritance
13
14 ```docker
15 FROM ruby:2.2.2
16 ```
17
18 ### Variables
19
20 ```docker
21 ENV APP_HOME /myapp
22 RUN mkdir $APP_HOME
23 ```
24
25 ```docker
26 ARG APP_HOME=""
27 RUN mkdir $APP_HOME
28 ```
29
30 ### Initialization
31
32 ```docker
33 RUN bundle install
34 ```
35
36 ```docker
37 WORKDIR /myapp
38 ```
39
40 ```docker
41 VOLUME ["/data"]
42 # Specification for mount point
43 ```
44
45 ```docker
46 ADD file.xyz /file.xyz
47 COPY --chown=user:group host_file.xyz /path/container_file.xyz
48 ```
49
50 ### Onbuild
51
52 ```docker
53 ONBUILD RUN bundle install
54 # when used with another file
55 ```
56
57 ### Commands
58
59 ```docker
60 EXPOSE 5900
61 CMD    ["bundle", "exec", "rails", "server"]
62 ```
63
64 ### Entrypoint
65
66 ```docker
67 ENTRYPOINT ["executable", "param1", "param2"]
68 ENTRYPOINT command param1 param2
69 ```
70
71 Configures a container that will run as an executable.
72
73 ```docker
74 ENTRYPOINT exec top -b
75 ```
76
77 This will use shell processing to substitute shell variables, and will ignore any `CMD` or `docker run` command line arguments.
78
79 ### Metadata
80
81 ```docker
82 LABEL version="1.0"
83 ```
84
85 ```docker
86 LABEL "com.example.vendor"="ACME Incorporated"
87 LABEL com.example.label-with-value="foo"
88 ```
89
90 ```docker
91 LABEL description="This text illustrates \
92 that label-values can span multiple lines."
93 ```
94
95 ## See also
96 {: .-one-column}
97
98 - <https://docs.docker.com/engine/reference/builder/>