02. Basic Usuage - Images
July 9, 2024Less than 1 minute
The docker will download image from remote repository during run a container based on a not existing image locally. The Docker hub is the public image repository.
List all local images
docker images
Pull a new image from remote repository
docker pull ubuntu:13.10
Search Images
docker search httpd
delete images
docker rmi hello-world
Create an Image
1. From a container
Update an image from a modified containerdocker commit -m="has update" -a="runoob" e218edb10161 runoob/ubuntu:v2
- -m: the commit comments
- -a: specify the image author
- e218edb10161: container id
- runoob/ubuntu:v2: the new name of the created image
2. build
Using the docker build
to build an image. The Dockerfile
is needed to tell how to build an image.
FROM centos:6.7
MAINTAINER Fisher "fisher@sudops.com"
RUN /bin/echo 'root:123456' |chpasswd
RUN useradd runoob
RUN /bin/echo 'runoob:123456' |chpasswd
RUN /bin/echo -e "LANG=\"en_US.UTF-8\"" >/etc/default/local
EXPOSE 22
EXPOSE 80
CMD /usr/sbin/sshd -D
FROM to specify the source of image.
RUN tell the commands in docker image.
Finally using the following command to build an image docker build -t runoob/centos:6.7 .
- -t: the new image name
- .: the folder of
Dockerfile
Setup image tag
docker tag <image id> <imagename>:<image tag>