docker:docker_images_vs._container

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
docker:docker_images_vs._container [2016/10/15 14:41] peterdocker:docker_images_vs._container [2020/07/15 09:30] (current) – external edit 127.0.0.1
Line 2: Line 2:
  
 Docker has images and containers.  The two are closely related, but distinct.  Docker has images and containers.  The two are closely related, but distinct. 
 +
 +----
  
 ===== Docker Images ===== ===== Docker Images =====
  
-An image is an inert, immutable, file that's essentially a snapshot of a container.  Images are created with the **[[http://docs.docker.com/reference/commandline/cli/#build|build]]** command, and they'll produce a container when started with **[[https://docs.docker.com/reference/run/|run]]**.  Images are stored in a Docker registry such as **[[https://registry.hub.docker.com/|registry.hub.docker.com]]**.  Because they can become quite large, images are designed to be composed of layers of other images, allowing minimal amount of data to be sent when transferring images over the network.+Images are basically template used to create containers.
  
-Local images can be listed by running+  * An image is an inert, immutable, file that's essentially a snapshot of a container. 
 +  * Images are created with the **[[http://docs.docker.com/reference/commandline/cli/#build|build]]** command, and they'll produce a container when started with **[[https://docs.docker.com/reference/run/|run]]**. 
 +  * Images are stored in a Docker registry such as **[[https://registry.hub.docker.com/|registry.hub.docker.com]]**. 
 +  * Because they can become quite large, images are designed to be composed of layers of other images, allowing a minimal amount of data to be sent when transferring images over the network. 
 + 
 +Local images can be listed by running:
  
 <code bash> <code bash>
-docker images:+docker images
 </code> </code>
  
-Returns:+returns:
  
-<code>+<code bash>
 REPOSITORY                TAG                 IMAGE ID            CREATED             VIRTUAL SIZE REPOSITORY                TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
 ubuntu                    13.10               5e019ab7bf6d        2 months ago        180 MB ubuntu                    13.10               5e019ab7bf6d        2 months ago        180 MB
Line 36: Line 43:
 More info on images is available from the [[https://docs.docker.com/terms/image/|Docker docs]]. More info on images is available from the [[https://docs.docker.com/terms/image/|Docker docs]].
  
 +----
  
 ===== Docker Containers ===== ===== Docker Containers =====
  
-To use a programming metaphor, if an image is a class, then a container is an instance of a class—a runtime object.  Containers are hopefully why you're using Docker; they're lightweight and portable encapsulations of an environment in which to run applications.+To use a programming metaphor, if an image is a class, then a container is an instance of a class — a runtime object. 
 + 
 +Containers are hopefully why you're using Docker; they're lightweight and portable encapsulations of an environment in which to run applications.
  
 View local running containers by running: View local running containers by running:
Line 47: Line 57:
 </code> </code>
  
-Returns:+returns:
  
-<code>+<code bash>
 CONTAINER ID        IMAGE                               COMMAND                CREATED             STATUS              PORTS                    NAMES CONTAINER ID        IMAGE                               COMMAND                CREATED             STATUS              PORTS                    NAMES
 f2ff1af05450        samalba/docker-registry:latest      /bin/sh -c 'exec doc   4 months ago        Up 12 weeks         0.0.0.0:5000->5000/tcp   docker-registry f2ff1af05450        samalba/docker-registry:latest      /bin/sh -c 'exec doc   4 months ago        Up 12 weeks         0.0.0.0:5000->5000/tcp   docker-registry
Line 60: Line 70:
   - **NAMES** can be used to identify a started container via the **<nowiki>--name</nowiki>** flag.   - **NAMES** can be used to identify a started container via the **<nowiki>--name</nowiki>** flag.
  
 +----
  
 ===== How to avoid image and container build-up ===== ===== How to avoid image and container build-up =====
Line 77: Line 88:
 </code> </code>
  
-These are known pain points with Docker, and may be addressed in future releases.  However, with a clear understanding of images and containers, these situations can be avoided with a couple of practices:+These are known pain points with Docker, and may be addressed in future releases. 
 + 
 +However, with a clear understanding of images and containers, these situations can be avoided with a couple of practices:
  
   - Always remove a useless, stopped container with **docker rm [CONTAINER_ID]**.   - Always remove a useless, stopped container with **docker rm [CONTAINER_ID]**.
   - Always remove the image behind a useless, stopped container with **docker rmi [IMAGE_ID]**.   - Always remove the image behind a useless, stopped container with **docker rmi [IMAGE_ID]**.
- 
  
docker/docker_images_vs._container.1476542481.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki