The docker thing has too many pits at the beginning, and the concept is not the same as before, so it is more troublesome to start, now record the process of creating an image from scratch to running docker
Step 1: Make an operating system image
Install:
yum -y install febootstrap
When using the root account to make an image, ordinary users will have various problems after making it:
Here I do centos7 operating system:
febootstrap -i bash -i wget -i yum -i iputils -i iproute centos7 centos7-doc http://mirrors.163.com/centos/7/os/x86_64/
(-i install package, centos7 operating system version, centos7-doc installation directory, and finally the source address)
After the above is successful:
cd centos7-doc/ tar -c .|docker import - centos7
(centos7 is the name of the docker image)
Execute: docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE centos7 latest abb462089c51 51 minutes ago 471.8 MB
To test the docker image, create a container:
docker run -t -i centos7 /bin/bash
after exit
docker ps -a
[admin@localhost root]$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
14c9afaf2f06 centos63-bash:latest /bin/bash 7 minutes ago Exited (0) 6 minutes ago insane_lalande
Start the container you just created:
docker start 14c9afaf2f06
Enter the started container:
docker attach 14c9afaf2f06
A simple mirror image is completed.
Export and import images for easy sharing of image files
Export image:
docker save IMAGENAME | bzip2 -9 -c>img.tar.bz2
Import the image (change a machine):
bzip2 -d -c <img.tar.bz2 | docker load