Operations 14 min read

Step‑by‑Step Guide to Pulling, Building, Committing, and Transferring Docker Images

This article explains how to obtain base images, use Docker Hub, pull images with docker pull, create images via Dockerfile, container commits, tag and push images, and import/export images between hosts using docker save and docker load, providing complete command examples and best‑practice tips.

Raymond Ops
Raymond Ops
Raymond Ops
Step‑by‑Step Guide to Pulling, Building, Committing, and Transferring Docker Images

In most cases we create Docker images based on an existing base image (for example, a minimal CentOS, Ubuntu, or Debian) which we call a base image .

The minimal CentOS image is provided by Docker Hub maintainers; creating it is straightforward for Docker staff but not for end users.

Docker Hub

Docker Hub is a cloud‑based registry service that lets you link to code repositories, build and test images, store manually pushed images, and connect to Docker Cloud for deployment. It provides centralized image discovery, distribution, change management, user and team collaboration, and workflow automation.

Key features of Docker Hub include:

Image repository

Search and pull images from community and official libraries; manage, push, and pull images from private repositories you have access to

Automated builds

Automatic image creation when source code changes

Web documentation

Webhooks to trigger actions after a successful push

Organizations and work‑groups for repository access control

GitHub and Bitbucket integration

Adding Docker images to your current workflow

Getting Docker Images

To pull an image from a remote registry (including your own Docker registry) use the

docker pull

command:

docker pull [registry][:port]/[namespace]/[image]:[tag]

Example:

<code>[root@localhost ~]# docker pull busybox</code>

After pulling you can run a container:

<code>[root@localhost ~]# docker run --name bi -it busybox</code>

To view the default process of a container, use

docker inspect

:

<code>[root@localhost ~]# docker inspect bi</code>

Image Generation

Images can be generated via:

Dockerfile

Commit from a running container

Docker Hub automated builds

Creating an Image from a Container

Modify a running container and commit it as a new image:

docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]

Common options:

<code>--author, -a        Author (e.g., "John Smith <[email protected]>")
-c, --change       Apply Dockerfile instructions to the created image
-m, --message      Commit message
-p, --pause        Pause container during commit (default: true)</code>

Example workflow:

<code>[root@localhost ~]# docker pull busybox
[root@localhost ~]# docker run --name bi -it busybox
/root@localhost ~# echo 'nihao' > data/index.html
[root@localhost ~]# docker commit -p bi
sha256:b726393438ac...<br/>[root@localhost ~]# docker tag b726393438ac luojialong123/v1
[root@localhost ~]# docker push luojialong123/v1</code>

When the default container process is

sh

but you need an HTTP server, set the command to

/bin/httpd -f -h /data

during commit.

Image Import and Export

To transfer an image between two hosts without pushing to a registry, export it to a file with

docker save

and import it on the target host with

docker load

.

<code># Export on host 1
docker save -o busybox.tar luojialong123/v1
# Transfer the file to host 2
# Import on host 2
docker load -i busybox.tar</code>

After loading, the image appears in

docker images

and can be used to create containers.

Example of creating a container from the imported image and exposing an HTTP service:

<code># Run container with port mapping
docker run --name t2 -d -p 80:80 luojialong123/v2
# Verify the service
curl 172.17.0.3</code>
DockeroperationsLinuxcontainerImageDocker Hub
Raymond Ops
Written by

Raymond Ops

Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.