Use vuepress build book

Signed-off-by: Kang HuaiShuai <khs1994@khs1994.com>
pull/432/head
Kang HuaiShuai 2019-10-29 14:31:45 +08:00
parent 7690686ddb
commit c788212aad
No known key found for this signature in database
GPG Key ID: 0A380828B1C243A7
35 changed files with 690 additions and 84 deletions

View File

@ -16,3 +16,17 @@ jobs:
uses: docker://yeasy/docker_practice
with:
args: build
- name: vuepress
run: |
npx vuepress build
- name: Upload Vuepress dist
uses: docker://pcit/pages
env:
PCIT_EMAIL: khs1994@khs1994.com
PCIT_GIT_TOKEN: ${{ secrets.PCIT_GIT_TOKEN }}
PCIT_GIT_URL: github.com/docker-practice/vuepress
PCIT_KEEP_HISTORY: "1"
PCIT_LOCAL_DIR: .vuepress/dist
PCIT_MESSAGE: Sync from yeasy/docker-practice@${{github.sha}} by PCIT
PCIT_TARGET_BRANCH: master
PCIT_USERNAME: khs1994

1
.gitignore vendored
View File

@ -7,3 +7,4 @@ _book/
*.edx
.DS_Store
node_modules/
.vuepress/dist

352
.vuepress/config.js Normal file
View File

@ -0,0 +1,352 @@
module.exports = {
title: 'Docker ',
base: '/',
themeConfig: {
docsRepo: 'yeasy/docker_practice',
docsDir: '/',
editLinks: true,
nav: [{
text: ' Docker',
link: '/install/',
},
{
text: 'Docker ',
link: '/'
},
{
text: 'Docker ',
link: '/cases/os/'
},
{
text: 'CI/CD',
link: '/cases/ci/'
},
{
text: 'Docker ',
link: '/repository/'
},
{
text: '',
link: '/underly/',
},
{
text: 'Compose',
link: '/compose/',
},
{
text: 'Kubernetes',
link: '/kubernetes/',
},
{
text: 'GitHub',
link: 'https://github.com/yeasy/docker_practice'
},
// {
// text: '捐赠',
// link: ''
// },
{
text: '',
link: 'https://cloud.tencent.com/redirect.php?redirect=10058&cps_key=3a5255852d5db99dcd5da4c72f05df61'
},
// {
// text: '语言',
// items: [{
// text: 'English',
// link: ''
// }]
// }
],
sidebar: {
'/kubernetes/': [
'intro',
'quickstart',
'concepts',
'kubectl',
'design',
],
'/compose/': [
'introduction',
'install',
'usage',
'commands',
'compose_file',
'django',
'rails',
'wordpress',
],
'/install/': [
'/install/',
'ubuntu',
'debian',
'fedora',
'centos',
'raspberry-pi',
'mac',
'windows',
'mirror',
],
'/underly/': [
'/underly/',
'arch',
'namespace',
'cgroups',
'ufs',
'container_format',
'network',
],
'/repository/': [
'/repository/',
'dockerhub',
'registry',
'registry_auth',
'nexus3_registry',
],
'/cases/os/': [
{
title: "操作系统",
collapsable:false,
children: [
'/cases/os/',
'busybox',
'alpine',
'debian',
'centos',
'summary',
],
},
],
'/cases/ci/': [
'/cases/ci/',
'/cases/ci/actions/',
{
title: "Drone",
collapsable: false,
children: [
'drone/',
'drone/install'
]
},
'travis/'
],
'/': [
'/',
'/CHANGELOG',
'/CONTRIBUTING',
{
title: "Docker 简介",
collapsable: false,
children: [
'/introduction/',
'/introduction/what',
'/introduction/why',
]
},{
title: "基本概念",
collapsable: false,
children: [
'/basic_concept/',
'/basic_concept/image',
'/basic_concept/container',
'/basic_concept/repository'
]
},
{
title: "使用镜像",
collapsable: false,
children: [
'/image/',
'/image/pull',
'/image/list',
'/image/rm',
'/image/commit',
'/image/build',
'/image/other.md',
'/image/internal.md',
]
},
{
title: 'Dockerfile',
collapsable: false,
children: [
"/image/dockerfile/",
'/image/dockerfile/copy',
'/image/dockerfile/add',
'/image/dockerfile/cmd',
'/image/dockerfile/entrypoint',
'/image/dockerfile/env',
'/image/dockerfile/arg',
'/image/dockerfile/volume',
'/image/dockerfile/expose',
'/image/dockerfile/workdir',
'/image/dockerfile/user',
'/image/dockerfile/healthcheck',
'/image/dockerfile/onbuild',
'/image/dockerfile/references',
'/image/multistage-builds/',
'/image/multistage-builds/laravel',
'/image/manifest',
'/image/buildx_multi-arch-images',
'/image/buildkit',
'/image/buildx',
]
},{
title: "操作容器",
collapsable: false,
children: [
'container/',
'container/run',
'container/daemon',
'container/stop',
'container/attach_exec',
'container/import_export',
'container/rm',
],
},
{
title: "数据管理",
collapsable:false,
children: [
'data_management/',
'data_management/volume',
'data_management/bind-mounts',
],
},{
title: "使用网络",
collapsable:false,
children: [
'network/',
'network/port_mapping',
'network/linking',
'network/dns',
],
},
{
title: "高级网络配置",
collapsable:false,
children: [
'advanced_network/',
'advanced_network/quick_guide',
'advanced_network/access_control',
'advanced_network/port_mapping',
'advanced_network/bridge',
'advanced_network/example',
'advanced_network/config_file',
'advanced_network/ptp',
],
},
{
title: "Swarm mode",
collapsable:false,
children: [
'swarm_mode/',
'swarm_mode/overview',
'swarm_mode/create',
'swarm_mode/deploy',
'swarm_mode/stack',
'swarm_mode/secret',
'swarm_mode/config',
'swarm_mode/rolling_update',
],
},
{
title: "安全",
collapsable: false,
children: [
'security/',
'security/kernel_ns',
'security/control_group',
'security/daemon_sec',
'security/kernel_capability',
'security/other_feature',
'security/summary',
],
},
{
title: "Etcd",
collapsable:false,
children: [
'etcd/',
'etcd/intro',
'etcd/install',
'etcd/cluster',
'etcd/etcdctl',
],
},
{
title: "Fedora CoreOS",
collapsable: false,
children: [
'coreos/',
'coreos/intro',
'coreos/intro_tools',
],
},
{
title: "容器与云计算",
collapsable:false,
children: [
'cloud/',
'cloud/intro',
'cloud/aws',
'cloud/tencentCloud',
'cloud/alicloud',
'cloud/summary',
],
},
{
title: "Docker 开源项目",
collapsable:false,
children:[
'opensource/',
'opensource/linuxkit',
],
},
{
title: "附录",
collapsable:false,
children: [
'appendix/',
'appendix/faq/',
'appendix/repo/',
'appendix/repo/ubuntu',
'appendix/repo/centos',
'appendix/repo/nginx',
'appendix/repo/php',
'appendix/repo/nodejs',
'appendix/repo/mysql',
'appendix/repo/wordpress',
'appendix/repo/mongodb',
'appendix/repo/redis',
'appendix/command/',
'appendix/best_practices',
'appendix/debug',
'appendix/resources'
],
},
{
title: "Docker Machine",
collapsable: false,
children: [
'machine/',
'machine/install',
'machine/usage',
],
},
{
title: 'Mesos',
collapsable: false,
children: [
'/mesos/intro',
'/mesos/installation',
'/mesos/architecture',
'/mesos/configuration',
'/mesos/monitor',
'/mesos/framework',
'/mesos/summary',
]
},
],
},
}
}

View File

@ -1,8 +1,9 @@
##
#
* 1.1.0 2019-12-31
* v19.x
* `BuildKit`
* `docker buildx` 使
* `docker manifest` 使
* `Ubuntu 14.04` `Debian 8` `Debian 7`

View File

@ -1,4 +1,4 @@
##
#
[Issue](https://github.com/yeasy/docker_practice/issues),如 [issue 235](https://github.com/yeasy/docker_practice/issues/235),添加自己为 `Assignee`。

View File

@ -42,7 +42,9 @@
* [Dockerfile ](image/multistage-builds/README.md)
* [ Laravel ](image/multistage-builds/laravel.md)
* [ Docker ](image/manifest.md)
* [使 BuildKit ](image/buildkit.md)
* [使 buildx Docker ](image/buildx_multi-arch-images.md)
* [Docker v18.09 使 BuildKit ](image/buildkit.md)
* [Docker v19.03 使 BuildKit ](image/buildx.md)
* [](image/other.md)
* [](image/internal.md)
* [](container/README.md)

View File

@ -36,7 +36,7 @@
`buildpack-deps`
```dockerfile
```docker
RUN apt-get update && apt-get install -y \
bzr \
cvs \
@ -72,7 +72,7 @@ RUN apt-get update && apt-get install -y \
>使使
```dockerfile
```docker
# Set one or more individual labels
LABEL com.example.version="0.0.1-beta"
@ -85,7 +85,7 @@ LABEL com.example.version.is-production=""
`LABEL`
```dockerfile
```docker
# Set multiple labels at once, using line-continuation characters to break long lines
LABEL vendor=ACME\ Incorporated \
com.example.is-beta= \
@ -108,7 +108,7 @@ LABEL vendor=ACME\ Incorporated \
`RUN apt-get update` `apt-get install` `RUN`
```dockerfile
```docker
RUN apt-get update && apt-get install -y \
package-bar \
package-baz \
@ -117,7 +117,7 @@ RUN apt-get update && apt-get install -y \
`apt-get update` `RUN` `apt-get install` `Dockerfile`
```dockerfile
```docker
FROM ubuntu:18.04
RUN apt-get update
@ -127,7 +127,7 @@ RUN apt-get install -y curl
Docker `apt-get install`
```dockerfile
```docker
FROM ubuntu:18.04
RUN apt-get update
@ -139,7 +139,7 @@ Docker 发现修改后的 `RUN apt-get update` 指令和之前的完全一样。
使 `RUN apt-get update && apt-get install -y` Dockerfiles `cache busting` `cache-busting`
```dockerfile
```docker
RUN apt-get update && apt-get install -y \
package-bar \
package-baz \
@ -150,7 +150,7 @@ RUN apt-get update && apt-get install -y \
`RUN` `apt-get`
```dockerfile
```docker
RUN apt-get update && apt-get install -y \
aufs-tools \
automake \
@ -193,7 +193,7 @@ RUN apt-get update && apt-get install -y \
`ENV`
```dockerfile
```docker
ENV PG_MAJOR 9.3
ENV PG_VERSION 9.3.4
@ -211,7 +211,7 @@ ENV PATH /usr/local/postgres-$PG_MAJOR/bin:$PATH
`Dockerfile` 使 `COPY` `COPY`
```dockerfile
```docker
COPY requirements.txt /tmp/
RUN pip install --requirement /tmp/requirements.txt
@ -223,7 +223,7 @@ COPY . /tmp/
使 `ADD` URL 使 `curl` `wget`
```dockerfile
```docker
ADD http://example.com/big.tar.xz /usr/src/things/
RUN tar -xJf /usr/src/things/big.tar.xz -C /usr/src/things
@ -233,7 +233,7 @@ RUN make -C /usr/src/things all
使
```dockerfile
```docker
RUN mkdir -p /usr/src/things \
&& curl -SL http://example.com/big.tar.xz \
| tar -xJC /usr/src/things \
@ -250,7 +250,7 @@ RUN mkdir -p /usr/src/things \
`s3cmd`:
```dockerfile
```docker
ENTRYPOINT ["s3cmd"]
CMD ["--help"]
@ -295,7 +295,7 @@ exec "$@"
`ENTRYPOINT`
```dockerfile
```docker
COPY ./docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]

View File

@ -52,11 +52,18 @@
### PID
使 `docker inspect --format '{{ .State.Pid }}' <CONTAINER ID or NAME>`
使
```bash
docker inspect --format '{{ .State.Pid }}' <CONTAINER ID or NAME>
```
### IP
使 `docker inspect --format '{{ .NetworkSettings.IPAddress }}' <CONTAINER ID or NAME>`
使
```bash
docker inspect --format '{{ .NetworkSettings.IPAddress }}' <CONTAINER ID or NAME>
```
### IP IP

View File

@ -1,4 +1,4 @@
## Docker
# Docker
`Image``Container` `` `实例`

View File

@ -1,10 +1,10 @@
## Docker
# Docker
Linux `root` Docker Image `root` `ubuntu:18.04` Ubuntu 18.04 `root`
Docker
###
##
`root` Docker [Union FS](https://en.wikipedia.org/wiki/Union_mount) 的技术,将其设计为分层存储的架构。所以严格来说,镜像并非是像一个 ISO 那样的打包文件,镜像只是一个虚拟的概念,其实际体现并非由一个文件组成,而是由一组文件系统组成,或者说,由多层文件系统联合组成。

View File

@ -1,4 +1,4 @@
## Docker Registry
# Docker Registry
宿使[Docker Registry](../repository/registry.md)
@ -10,7 +10,7 @@
** `jwilder/nginx-proxy` Docker Registry 使 Docker Registry
### Docker Registry
## Docker Registry
Docker Registry 使 Registry
@ -20,7 +20,7 @@ Docker Registry 公开服务是开放给用户使用、允许用户管理镜像
Docker Hub [](https://hub.tenxcloud.com/)、[网易云镜像服务](https://c.163.com/hub#/m/library/)、[DaoCloud 镜像市场](https://hub.daocloud.io/)、[阿里云镜像库](https://cr.console.aliyun.com) 等。
### Docker Registry
## Docker Registry
使 Docker RegistryDocker [Docker Registry](https://hub.docker.com/_/registry/) 镜像,可以直接使用做为私有 Registry 服务。在 [私有仓库](../repository/registry.md) 一节中,会有进一步的搭建私有 Registry 服务的讲解。

View File

@ -10,7 +10,7 @@
`Dockerfile`
```dockerfile
```docker
FROM alpine
RUN echo "Hello World"

View File

@ -8,7 +8,7 @@
Docker `Dockerfile` Docker
```dockerfile
```docker
FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir /code

View File

@ -8,7 +8,7 @@
Docker `Dockerfile` Docker
```dockerfile
```docker
FROM ruby
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev
RUN mkdir /myapp
@ -117,5 +117,3 @@ $ docker-compose run web rake db:create
```
web docker 3000
![](../_images/docker-compose-rails-screenshot.png)

View File

@ -40,7 +40,7 @@ if __name__ == "__main__":
`Dockerfile`
```dockerfile
```docker
FROM python:3.6-alpine
ADD . /code
WORKDIR /code

View File

@ -16,7 +16,7 @@ $ touch Dockerfile
```dockerfile
```docker
FROM nginx
RUN echo '<h1>Hello, Docker!</h1>' > /usr/share/nginx/html/index.html
```
@ -33,7 +33,7 @@ RUN echo '<h1>Hello, Docker!</h1>' > /usr/share/nginx/html/index.html
Docker `scratch`
```dockerfile
```docker
FROM scratch
...
```
@ -48,7 +48,7 @@ FROM scratch
* *shell* `RUN <命令>` Dockerfile `RUN`
```Dockerfile
```docker
RUN echo '<h1>Hello, Docker!</h1>' > /usr/share/nginx/html/index.html
```
@ -56,7 +56,7 @@ RUN echo '<h1>Hello, Docker!</h1>' > /usr/share/nginx/html/index.html
`RUN` Shell Shell RUN
```dockerfile
```docker
FROM debian:stretch
RUN apt-get update
@ -77,7 +77,7 @@ RUN make -C /usr/src/redis install
`Dockerfile`
```dockerfile
```docker
FROM debian:stretch
RUN buildDeps='gcc libc6-dev make wget' \
@ -142,7 +142,7 @@ docker build [选项] <上下文路径/URL/->
`Dockerfile`
```Dockerfile
```docker
COPY ./package.json /app/
```

View File

@ -6,7 +6,7 @@
**docker-compose build BuildKit**
Docker CE 18.09+ 使 `BuildKit` `Dockerfile` Docker
Docker CE 18.09 使 `BuildKit` `Dockerfile` Docker
### `BuildKit`

148
image/buildx.md Normal file
View File

@ -0,0 +1,148 @@
## 使 `Buildx`
**BuildKit** https://github.com/moby/buildkit 开源。
**使Docker Hub Docker 18.09BuildKit 使使 BuildKit 使 Dockerfile Dockerfile.buildkit**
Docker CE 19.03+ 使 `BuildKit` `Dockerfile` Docker
### `Dockerfile`
`BuildKit` 使使 `BuildKit` **** 使 `$ docker buildx build` Docker
#### `RUN --mount=type=cache`
使 `Go` `go mod``Node.js` `npm`
`npm`
```docker
FROM node:alpine as builder
WORKDIR /app
COPY package.json /app/
RUN npm i --registry=https://registry.npm.taobao.org \
&& rm -rf ~/.npm
COPY src /app/src
RUN npm run build
FROM nginx:alpine
COPY --from=builder /app/dist /app/dist
```
使 `dist` `package.json` `RUN npm i && rm -rf ~/.npm`
**** `node_modules` `node_modules` `node_modules`
`BuildKit` `RUN --mount=type=cache`
```docker
FROM node:alpine as builder
WORKDIR /app
COPY package.json /app/
RUN --mount=type=cache,target=/app/node_modules,id=my_app_npm_module,sharing=locked \
--mount=type=cache,target=/root/.npm,id=npm_cache \
npm i --registry=https://registry.npm.taobao.org
COPY src /app/src
RUN --mount=type=cache,target=/app/node_modules,id=my_app_npm_module,sharing=locked \
# --mount=type=cache,target=/app/dist,id=my_app_dist,sharing=locked \
npm run build
FROM nginx:alpine
# COPY --from=builder /app/dist /app/dist
# from source 使 RUN
RUN --mount=type=cache,target=/tmp/dist,from=builder,source=/app/dist \
# --mount=type=cache,target/tmp/dist,from=my_app_dist,sharing=locked \
mkdir -p /app/dist && cp -r /tmp/dist/* /app/dist
```
`RUN` `id` `my_app_npm_module` `/app/node_modules`
`RUN` `node_modules` `node_modules`
`RUN` `from` `builder` `source`
`Dockerfile` `--mount=type=cache,...`
|Option |Description|
|---------------------|-----------|
|`id` | `id` 便|
|`target` () | |
|`ro`,`readonly` | |
|`sharing` | `shared` `private` `locked` `sharing` 使 `BuildKit` 使 `id``shared` `private` 使使`locked` 使|
|`from` | |
|`source` | |
#### `RUN --mount=type=bind`
```docker
RUN --mount=type=bind,from=php:alpine,source=/usr/local/bin/docker-php-entrypoint,target=/docker-php-entrypoint \
cat /docker-php-entrypoint
```
#### `RUN --mount=type=tmpfs`
`tmpfs`
```docker
RUN --mount=type=tmpfs,target=/temp \
mount | grep /temp
```
#### `RUN --mount=type=secret`
```docker
RUN --mount=type=secret,id=aws,target=/root/.aws/credentials \
cat /root/.aws/credentials
```
```bash
$ docker buildx build -t test --secret id=aws,src=$HOME/.aws/credentials .
```
#### `RUN --mount=type=ssh`
`ssh`
```docker
FROM alpine
RUN apk add --no-cache openssh-client
RUN mkdir -p -m 0700 ~/.ssh && ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
RUN --mount=type=ssh ssh git@gitlab.com | tee /hello
```
```bash
$ eval $(ssh-agent)
$ ssh-add ~/.ssh/id_rsa
(Input your passphrase here)
$ docker buildx build -t test --ssh default=$SSH_AUTH_SOCK .
```
###
```bash
$ docker builder prune
```
###
* https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/experimental.md

View File

@ -0,0 +1,78 @@
# 使 buildx Docker
Docker 使使 [`$ docker manifest`](manifest.md)
Docker 19.03+ 使 `$ docker buildx build` 使 `BuildKit`
`--platform` Docker
##
`buildx` 使
Linux/macOS
```bash
$ export DOCKER_CLI_EXPERIMENTAL=enabled
```
Windows
```bash
$ set $env:DOCKER_CLI_EXPERIMENTAL=enabled
```
## `builder`
Docker for Linux `arm` Docker
```bash
$ docker run --rm --privileged docker/binfmt:820fdd95a9972a5308930a2bdfb8573dd4447ad3
```
Docker `builder` `--platform` `builder`
```bash
$ docker buildx create --name mybuilder
$ docker buildx use mybuilder
```
##
Dockerfile
```docker
FROM --platform=$TARGETPLATFORM alpine
RUN uname -a > /os.txt
CMD cat /os.txt
```
使 `$ docker buildx build` `myusername` Docker Hub
`--push` Docker
```bash
$ docker buildx build --platform linux/arm,linux/arm64,linux/amd64 -t myusername/hello . --push
#
$ docker buildx imagetools inspect myusername/hello
```
```bash
# arm
$ docker run -it --rm myusername/hello
Linux buildkitsandbox 4.9.125-linuxkit #1 SMP Fri Sep 7 08:20:28 UTC 2018 armv7l Linux
# arm64
$ docker run -it --rm myusername/hello
Linux buildkitsandbox 4.9.125-linuxkit #1 SMP Fri Sep 7 08:20:28 UTC 2018 aarch64 Linux
# amd64
$ docker run -it --rm myusername/hello
Linux buildkitsandbox 4.9.125-linuxkit #1 SMP Fri Sep 7 08:20:28 UTC 2018 x86_64 Linux
```

View File

@ -21,7 +21,7 @@ $ docker run --name webserver -d -p 80:80 nginx
访 Nginx
<img src="_images/images-mac-example-nginx.png" width="80%" >
![](_images/images-mac-example-nginx.png)
Docker 使 `docker exec`
@ -38,7 +38,7 @@ exit
<img src="_images/images-create-nginx-docker.png" width="80%" >
![](_images/images-create-nginx-docker.png)
`docker diff`

View File

@ -0,0 +1,5 @@
FROM --platform=$TARGETPLATFORM alpine
RUN uname -a > /os.txt
CMD cat /os.txt

View File

@ -8,7 +8,7 @@
`ubuntu`
```Dockerfile
```docker
FROM scratch
ADD ubuntu-xenial-core-cloudimg-amd64-root.tar.gz /
...
@ -24,7 +24,7 @@ ADD ubuntu-xenial-core-cloudimg-amd64-root.tar.gz /
使 `--chown=<user>:<group>`
```Dockerfile
```docker
ADD --chown=55:mygroup files* /mydir/
ADD --chown=bin files* /mydir/
ADD --chown=1 files* /mydir/

View File

@ -14,13 +14,13 @@
使 `shell` `sh -c`
```Dockerfile
```docker
CMD echo $HOME
```
```Dockerfile
```docker
CMD [ "sh", "-c", "echo $HOME" ]
```
@ -32,7 +32,7 @@ Docker 不是虚拟机,容器中的应用都应该以前台执行,而不是
`CMD`
```Dockerfile
```docker
CMD service nginx start
```
@ -44,6 +44,6 @@ CMD service nginx start
`nginx`
```Dockerfile
```docker
CMD ["nginx", "-g", "daemon off;"]
```

View File

@ -9,13 +9,13 @@
`COPY` `<源路径>` / `<目标路径>`
```Dockerfile
```docker
COPY package.json /usr/src/app/
```
`<源路径>` Go [`filepath.Match`](https://golang.org/pkg/path/filepath/#Match) 规则,如:
```Dockerfile
```docker
COPY hom* /mydir/
COPY hom?.txt /mydir/
```
@ -26,7 +26,7 @@ COPY hom?.txt /mydir/
使 `--chown=<user>:<group>`
```Dockerfile
```docker
COPY --chown=55:mygroup files* /mydir/
COPY --chown=bin files* /mydir/
COPY --chown=1 files* /mydir/

View File

@ -16,7 +16,7 @@
IP `CMD`
```Dockerfile
```docker
FROM ubuntu:18.04
RUN apt-get update \
&& apt-get install -y curl \
@ -48,7 +48,7 @@ $ docker run myip curl -s https://ip.cn -i
使 `ENTRYPOINT` `ENTRYPOINT`
```Dockerfile
```docker
FROM ubuntu:18.04
RUN apt-get update \
&& apt-get install -y curl \
@ -91,7 +91,7 @@ Connection: keep-alive
`CMD` `CMD` `ENTRYPOINT` `<CMD>` `redis`
```Dockerfile
```docker
FROM alpine:3.4
...
RUN addgroup -S redis && adduser -S -G redis redis

View File

@ -16,7 +16,7 @@ ENV VERSION=1.0 DEBUG=on \
使 `node` `Dockerfile`
```Dockerfile
```docker
ENV NODE_VERSION 7.2.0
RUN curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" \

View File

@ -25,7 +25,7 @@
Web Web `curl` `Dockerfile` `HEALTHCHECK`
```Dockerfile
```docker
FROM nginx
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*
HEALTHCHECK --interval=5s --timeout=3s \

View File

@ -8,7 +8,7 @@
Node.js Node.js 使 `npm` `package.json` `npm install` `npm start` `Dockerfile`
```Dockerfile
```docker
FROM node:slim
RUN mkdir /app
WORKDIR /app
@ -24,7 +24,7 @@ CMD [ "npm", "start" ]
使 `Dockerfile` `Dockerfile`
```Dockerfile
```docker
FROM node:slim
RUN mkdir /app
WORKDIR /app
@ -33,7 +33,7 @@ CMD [ "npm", "start" ]
`my-node` `Dockerfile`
```Dockerfile
```docker
FROM my-node
COPY ./package.json /app
RUN [ "npm", "install" ]
@ -46,7 +46,7 @@ COPY . /app/
`ONBUILD` `ONBUILD` `Dockerfile`:
```Dockerfile
```docker
FROM node:slim
RUN mkdir /app
WORKDIR /app
@ -58,7 +58,7 @@ CMD [ "npm", "start" ]
`Dockerfile` `ONBUILD` `Dockerfile`
```Dockerfile
```docker
FROM my-node
```

View File

@ -6,7 +6,7 @@
`WORKDIR` `USER`
```Dockerfile
```docker
RUN groupadd -r redis && useradd -r -g redis redis
USER redis
RUN [ "redis-server" ]
@ -14,7 +14,7 @@ RUN [ "redis-server" ]
`root` 使 `su` `sudo` TTY 使 [`gosu`](https://github.com/tianon/gosu)。
```Dockerfile
```docker
# redis 使 gosu
RUN groupadd -r redis && useradd -r -g redis redis
# gosu

View File

@ -7,7 +7,7 @@
(volume) Docker `Dockerfile`
```Dockerfile
```docker
VOLUME /data
```

View File

@ -2,11 +2,11 @@
使 Docker 宿 `Linux x86_64` 使 `Linux x86_64`
> macOS 使 [binfmt_misc](https://docs.docker.com/docker-for-mac/multi-arch/) 提供了多种架构支持,在 macOS 系统上 (x86_64) 可以运行 arm 等其他架构的镜像。
> WindowsmacOS 使 [binfmt_misc](https://docs.docker.com/docker-for-mac/multi-arch/) 提供了多种架构支持,在 Windows、macOS 系统上 (x86_64) 可以运行 arm 等其他架构的镜像。
`Linux x86_64` `username/test`
```Dockerfile
```docker
FROM alpine
CMD echo 1

View File

@ -26,7 +26,7 @@ func main(){
`Dockerfile.one`
```dockerfile
```docker
FROM golang:1.9-alpine
RUN apk --no-cache add git ca-certificates
@ -56,7 +56,7 @@ $ docker build -t go/helloworld:1 -f Dockerfile.one .
`Dockerfile.build`
```dockerfile
```docker
FROM golang:1.9-alpine
RUN apk --no-cache add git
@ -71,7 +71,7 @@ RUN go get -d -v github.com/go-sql-driver/mysql \
`Dockerfile.copy`
```dockerfile
```docker
FROM alpine:latest
RUN apk --no-cache add ca-certificates
@ -125,7 +125,7 @@ go/helloworld 1 f55d3e16affc 2 minutes ago 295MB
`Dockerfile`
```dockerfile
```docker
FROM golang:1.9-alpine as builder
RUN apk --no-cache add git
@ -172,7 +172,7 @@ go/helloworld 1 f55d3e16affc 2 minutes ago 295MB
使 `as`
```dockerfile
```docker
FROM golang:1.9-alpine as builder
```
@ -186,6 +186,6 @@ $ docker build --target builder -t username/imagename:tag .
使 `COPY --from=0 /go/src/github.com/go/helloworld/app .`
```dockerfile
```docker
$ COPY --from=nginx:latest /etc/nginx/nginx.conf /nginx.conf
```

View File

@ -50,7 +50,7 @@ server {
```dockerfile
```docker
FROM node:alpine as frontend
COPY package.json /app/
@ -69,7 +69,7 @@ RUN cd /app \
Composer
```dockerfile
```docker
FROM composer as composer
COPY database/ /app/database/
@ -89,7 +89,7 @@ RUN cd /app \
```dockerfile
```docker
FROM php:7.2-fpm-alpine as laravel
ARG LARAVEL_PATH=/app/laravel
@ -113,7 +113,7 @@ RUN cd ${LARAVEL_PATH} \
### NGINX
```dockerfile
```docker
FROM nginx:alpine as nginx
ARG LARAVEL_PATH=/app/laravel
@ -164,7 +164,7 @@ $ docker run -it --rm --network=laravel -p 8080:80 my/nginx
`Dockerfile`
```dockerfile
```docker
FROM node:alpine as frontend
COPY package.json /app/

View File

@ -1,4 +1,4 @@
## Docker
# Docker
**Docker** `dotCloud` [Solomon Hykes](https://github.com/shykes) 在法国期间发起的一个公司内部项目,它是基于 `dotCloud` 公司多年云服务技术的一次革新,并于 [2013 年 3 月以 Apache 2.0 授权协议开源][docker-soft],主要项目代码在 [GitHub](https://github.com/moby/moby) 上进行维护。`Docker` 项目后来还加入了 Linux 基金会,并成立推动 [开放容器联盟OCI](https://www.opencontainers.org/)。

View File

@ -1,20 +1,20 @@
## 使 Docker
# 使 Docker
`Docker`
###
##
`Docker`
###
##
`Docker` 宿
###
##
bug `Docker` **
###
##
[DevOps](https://zh.wikipedia.org/wiki/DevOps))人员来说,最希望的就是一次创建或配置,可以在任意地方正常运行。
@ -22,15 +22,15 @@
使 [`Dockerfile`](../image/build.md) 使便
###
##
`Docker` 使`Docker`
###
##
`Docker` 使使使`Docker` [](https://hub.docker.com/search/?type=image&image_filter=official),既可以直接在生产环境使用,又可以作为基础进一步定制,大大的降低了应用服务的镜像制作成本。
###
##
| | | |
| :-------- | :-------- | :---------- |