The Docker Book

 The Docker Book

James Turnbull August 26, 2019 Version: v18.09.2 (c2c5fa8) Website: The Docker Book

Some rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic,

mechanical or photocopying, recording, or otherwise, for commercial purposes without the prior permission of the publisher.

This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License. To view a copy of

this license, visit here.

? Copyright 2016 - James Turnbull

Contents

Page

Chapter 1 Working with Docker images and repositories

1

What is a Docker image? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Listing Docker images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Pulling images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

Searching for images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

Building our own images . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

Creating a Docker Hub account . . . . . . . . . . . . . . . . . . . . . . 13

Using Docker commit to create images . . . . . . . . . . . . . . . . . 15

Building images with a Dockerfile . . . . . . . . . . . . . . . . . . . . 18

Building the image from our Dockerfile . . . . . . . . . . . . . . . . . 22

What happens if an instruction fails? . . . . . . . . . . . . . . . . . . 25

Dockerfiles and the build cache . . . . . . . . . . . . . . . . . . . . . . 27

Using the build cache for templating . . . . . . . . . . . . . . . . . . . 27

Viewing our new image . . . . . . . . . . . . . . . . . . . . . . . . . . 29

Launching a container from our new image . . . . . . . . . . . . . . 30

Dockerfile instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

Pushing images to the Docker Hub . . . . . . . . . . . . . . . . . . . . . . 58

Automated Builds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

Deleting an image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

Running your own Docker registry . . . . . . . . . . . . . . . . . . . . . . 66

Running a registry from a container . . . . . . . . . . . . . . . . . . . 66

Testing the new registry . . . . . . . . . . . . . . . . . . . . . . . . . . 67

i

Contents

Alternative Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 Quay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

List of Figures

71

List of Listings

75

Index

76

Version: v18.09.2 (c2c5fa8)

ii

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download