1. Docker basic operation
Docker requires that the kernel version of the Ubuntu system is higher than 3.10
View your current kernel version via the Uname -R command
makefile
For example: Create a makefile file (Docker mirroring of the SpringBoot project_The Star Programming-Programmer Homesometer_Preis SpringBoot mirror
https://blog.csdn.net/junmoxi/article/details/79996524)
1. Create a folder CMD
sudo mkdier cmd
2, create a makefile file in CMD files
sudo touch makefile
The content is as follows:
FROM ubuntu
MAINTAINER tan
COPY jdk1.8.0_151 jdk1.8.0_151
COPY web web
RUN chmod 777 ./web/WEB-INF/*
ENV JAVA_HOME=/jdk1.8.0_151
ENV PATH=$JAVA_HOME/bin:$PATH
ENV CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
EXPOSE 7070
ENTRYPOINT ["nohup","./web/WEB-INF/startup_dev.sh","&"]
3, compile and generate mirror image (. Represents the current path)
docker build -t mirrorweb:v1.0 .
mirrorweb mirror name
v1.0 mirror version number
4. Start the container from the image
docker run --net=host -e JAVA_OPTS='-Xms128m -Xmx256m -Dspring.profiles.active=prod' -p 8080:8080 -t -d mirror:v1.0
5. View container running log
docker Logs command
docker logs [options] [container]
For example: Printing container mytest application 10 lines after 10 lines
docker logs –tail=”10″ mytest
Print real -time:
docker attach [container]
name |
default value |
Description |
–details |
Display extra details provided to the log |
|
—Follow or -F |
Output according to the log |
|
–since |
Starting from some time, for example, 2013-01-02T13: 23: 37 |
|
–tail |
all |
how many lines do you start from the end of the log |
–TimeStamps or -T |
Display time stamp |
|
–until |
Print a log before a certain time, such as 2013-01-02T13: 23: 37 |
6, maven packaging mirror image
mvn package docker:build
2. Install the docker in the script in ubuntu
1. Get the latest version of the docker installation package
wget -qO- https://get.docker.com/ | sh
2. Start the docker background service
sudo service docker start
3. Test run Hello-WORLD
docker run hello-world
4. View the operating container
docker ps
5. View the exit container
docker ps -a
6. Delete the container
docker RM [container ID]
7. Delete the image (want to delete the running Images must first delete its container)
docker RMI [Mirror ID]
docker RMI mirror name: tag
8. Enter the container
docker exec -it [container ID] /bin /bash
docker exec -it -user root [container ID] /bin /bash (root permission to enter)
9. Exit container
ctrl+d
10. Copy the host file to a directory of the container
docker cp [filepath in master] [container name]:[path in container]
11. View container details
docker inspect [container ID]
12. View docker network
docker network ls
3. Docker opens remote API
ubuntu
1. Modify Dokcer configuration file
vim /lib/systemd/system/docker.service
2. Modify ExecStart configuration
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock
3, save
service docker restart
If the following warnings appear, please execute the SystemCTL DAEMON-Reload before restart the docker
4. Visit in the browserhttp://ip:4243/images/jsonSuccess and explanation to open success
4. Docker import export
Mirror saving/load:docker load/docker save;
Export a mirror as a file, and then use the Docker Load command to import the file into a mirror image, which will save all historical records of the mirror. It is better to understand than the file exported by the Docker Export command, because it will save all historical records of the image.
container import/export:docker import/docker export;
Export a container as a file, and then use the Docker Import command to introduce the container into a new image, but compared to the Docker Save command, the container file will lose all metadata and historical records. Virtual machine snapshot
mirror export
docker save -o [package name].tar [mirror]
For example:
docker save -o images.tar mongo:3.4
Mirror introduction
docker load -i [package name].tar
For example:
docker load -i jdk.tar
container export
Docker Export [Container_id]> [Container Express Name]
For example:
docker export devcie>device.tar
container import
docker import [container express name]
For example:
docker import device.tar