Linux command learning - docker container is a good thing, no need to configure the environment

1. The command to transfer files between two server machines:

Join two machines A and B;

A: [email protected]

B: [email protected]

Assuming that you are now under the target path of machine B, you need to transfer the abc folder on machine A and the various files below:

scp -r [email protected]:workspace/abc .

Or specify to transfer the abc folder on the A machine to the specified B directory, remember to add -r:

scp -r [email protected]:/workspace/abc [email protected]:/something/someth

2. Transfer the docker container between two machines (in order not to configure the environment on the new machine, download files, etc., docker is convenient)

(Goal: put the container on A to run on the B server)

(1) First package the container on the A machine into a tar file for subsequent transmission;

docker export -o <path/container name.tar> <container name or container id>

e.g. docker export -o /data/yuyang/yuyang_docker.tar 94xx22xxx509001

(2) Then use scp to transfer the packaged tar file to machine B

scp <source path/container name.tar> <target username>@<target IP>:/<target path>

eg scp /data/yuyang/yuyang_docker.tar dazhuang @ 20.102.103.20:/home/yuyang

If the docker is relatively large, it may take a while

(3) Import this tar as an image mirror into the existing image mirror list on B

docker import <container name.tar> <new container name>

At this point, the image has been updated, and the required image (that is, the image, used to create a container that can run code) is available, but the container cannot be used directly at this time 

(4) From the image to the container that can actually run the code

docker run -itd --name <customize a container name> <image name imported above> /bin/bash

(5) Check whether your container is running normally

docker ps -a can view the status of all current containers

Guess you like

Origin blog.csdn.net/fantastick99/article/details/131798510