1. Build a docker image by Dockerfile (without file extension)
$ docker build .
2. Build image by a Dockfile with filepath
$ docker build -f /path/to/a/Dockerfile .
3.Build an image with tag name
$ docker build -t shykes/myapp . # or build duplicated images $ docker build -t shykes/myapp:1.0.2 -t shykes/myapp:latest .
Build cache is only used from images that have a local parent chain. This means that these images were created by previous builds or the whole chain of images was loaded withdocker load
. If you wish to use build cache of a specific image you can specify it with--cache-from
option. Images specified with--cache-from
do not need to have a parent chain and may be pulled from other registries.
BuildKit
Starting with version 18.09, Docker supports a new backend for executing your builds that is provided by the moby/buildkit project. The BuildKit backend provides many benefits compared to the old implementation. For example, BuildKit can:
- Detect and skip executing unused build stages
- Parallelize building independent build stages
- Incrementally transfer only the changed files in your build context between builds
- Detect and skip transferring unused files in your build context
- Use external Dockerfile implementations with many new features
- Avoid side-effects with rest of the API (intermediate images and containers)
- Prioritize your build cache for automatic pruning
To use the BuildKit backend, you need to set an environment variable
DOCKER_BUILDKIT=1
on the CLI before invokingdocker build
.
4. Docker Languages Type:
# Comment
INSTRUCTION arguments
5. Go into the container of docker.
docker exec -it <ContainerID> /bin/bash
*on alpine, no bash but sh. /bin/sh will be ok
6. docker -v
docker run -it -v c:\Data:c:\shareddata microsoft/windowsservercore powershell
没有评论:
发表评论