Docker packages the conda environment + code and uploads it to Docker Hub [denied: requested access to the resource is denied]

The Ultimate Stitcher!

Record Docker packaging conda environment + code & upload to your own Docker hub

1. Start by installing Docker

  1. Install the yum tool

    yum install -y yum-utils device-mapper-persistent-data lvm2 --skip-broken

  2. Set docker image source

    yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

    sed -i 's/download.docker.com/mirrors.aliyun.com\/docker-ce/g' /etc/yum.repos.d/docker-ce.repo

    yum makecache fast

  3. Install Docker

    yum install -y docker-ce

  4. First enter: sudo systemctl start docker, then enter: sudo systemctl enable docker

    sudo systemctl start docker

    sudo systemctl enable docker

Docker installation over

2. Package the Conda project into a mirror image

  1. First install a miniconda-based image

    docker pull continuumio/miniconda3

  2. into the container

    docker run --name test -idt continuumio/miniconda3

    -d in -idt specifies the running mode of the container, allowing the docker service to run in the background.

  3. Take a look at the list of containers

    docker ps -a

  4. Enter the test container and check the conda location

    docker exec -it test /bin/bash

    View conda location:conda info --envs

    After viewing, exit the container:exit

  5. Copy the local environment into docker in the local environment

    After exiting the container, copy what needs to be packaged locally to docker in the local environment

    docker cp /root/miniconda3/envs/你的conda环境 test:/opt/conda/envs

    • /home/b/miniconda3/envs/pipe is the local environment that needs to be packaged
    • test is the container name, and /opt/conda is the root directory of conda in the container.
  6. Then enter the container to check whether the environment is copied successfully

    docker exec -it test /bin/bash

    conda info --envs

    exit

  7. Copy native code into docker in local environment

    After exiting the container, copy the code to be packaged into docker in the local environment

    docker cp /data/代码路径 test:/root/

    docker exec -it test /bin/bash

    ls /root/

    exit

  8. Save the container as an image

    docker commit -a '你的名字' -m '代码描述' test image_test

    • -a: author
    • -m: submit description information
    • test: container name
    • image_test: the name of the saved image
  9. Save the image as a compressed package [this step can directly send the compressed package to another machine without using the docker hub]

    docker save -o test_tar.tar image_test

    • test_tar.tar: compressed package name
    • image_test: image name

Read the image [If you use a compressed package, it is the 9th step above to see here]

  1. Copy the packaged image compression package to the host machine.

  2. cd to the compressed package directory, execute:

    docker load -i test_tar.tar

  3. Create a container named create_test with the image_test image:
    docker run --name create_test -idt image_test

  4. If you need to map the files in the container with the files outside the container, use the following command to create the container:
    docker run --name create_test -v /home/path:/root/ -idt image_test
    -v host path container path: This command can map the host path to the container path when creating the container. This allows direct access to host folders within the container.

  5. into the container:docker exec -it create_test /bin/bash

upload mirror

  1. Login to Docker Hub:

    After the user completes the registration on Docker Hub, create a repository.
    insert image description here

    Then log in on the command line

    docker login -u <用户名>

    Success display: Login Succeeded

    quit:docker logout

  2. Tag the local image

    docker tag image name and tag

    docker tag local-image:tagname new-repo:tagname

    Attach the command to delete the mirror:docker rmi <image>

  3. upload mirror

    Users can use the docker push command to upload the image created by themselves to the warehouse for sharing.

    docker push new-repo:tagname

    This step may appear [denied: requested access to the resource is denied] this problem

    Possible solutions are: 1. Login again 2. Make sure you have created a repository in docker hub, and then the tag should be the same as the name of the created repository. You can refer to the tips given on the official website of docker hub: 3. If the network is not good, try insert image description here
    again How many times, just in case the internet is ready

Over!

Acho que você gosta

Origin blog.csdn.net/weixin_65656674/article/details/129448811
Recomendado
Clasificación