官术网_书友最值得收藏!

Building an image from a Dockerfile

Now that you have a Dockerfile, you use the docker command line to build it into an image. Like most Docker commands, the image build command is straightforward and has very few required options, preferring conventions instead. To build an image, open a command line and navigate to the directory where your Dockerfile is. Then, run docker image build and give your image a tag, which is the name that will identify the image:

docker image build --tag dockeronwindows/ch02-powershell-env .

Every image needs a tag, specified with the --tag option, which is a unique identifier for the image in your local image cache and in image registries. The tag is how you'll refer to the image when you run containers. A full tag specifies the registry to use, the repository name, which is the identifier for the application and a suffix, which is the identifier for this version of the image.

When you're building an image for yourself, you can call it anything, but the convention is to name your repository as your username for the registry, followed by the application name: {user}/{app}. You can use also the tag to identify application versions or variations, such as sixeyed/hadoop-dot-net:latest and sixeyed/hadoop-dot-net:2.7.2, which are two of my images on Docker Hub.

The period at the end of the image build command tells Docker the location of the context to use for the image, . is the current directory. Docker copies the contents of the directory tree into a temporary folder for the build, so the context needs to contain any files you reference in the Dockerfile. After copying the context, Docker starts executing the instructions in the Dockerfile.

主站蜘蛛池模板: 东宁县| 友谊县| 益阳市| 泉州市| 徐汇区| 宁德市| 通城县| 茶陵县| 瓮安县| 康保县| 息烽县| 锦屏县| 琼结县| 新龙县| 黑河市| 康定县| 鄂托克前旗| 岢岚县| 谢通门县| 浦北县| 大安市| 尼木县| 红安县| 平乡县| 蕲春县| 东安县| 彰武县| 石棉县| 承德县| 承德县| 和林格尔县| 耒阳市| 临湘市| 平塘县| 泽库县| 大埔县| 大丰市| 吉林市| 高阳县| 德昌县| 关岭|