Translate

Showing posts with label docker. Show all posts
Showing posts with label docker. Show all posts

Dockerfile构建速度过慢,更换国内源方法 (apt / pip)

apt方法:

       在Dockerfile中添加如下两句代码:

RUN  sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list

RUN  apt-get clean


* /archive.ubuntu.com/        ->        /原本的地址(可以在/etc/apt/sources.list中查看)/




pip方法:

        在Dockerfile中添加:

RUN pip install -U pip

RUN pip config set global.index-url http://mirrors.aliyun.com/pypi/simple

RUN pip config set install.trusted-host mirrors.aliyun.com


or


RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn -r requirements.txt






Some commands for docker

install docker:

curl -fsSL https://test.docker.com -o test-docker.sh sudo sh test-docker.sh

  1. list the containers: docker ps
  2. list all the containers: docker ps -a
  3. list the images: docker images
  4. change another image name: docker tag name1 name2
  5. commit the change to image: docker commit id name
  6. delete the image: docker rmi name
  7. stop a container: docker stop name
  8. remove a container: docker rm name
  • enter into a container: 
docker exec -it Name /bin/bash
  • save a image:
docker save image_name > Name.tar
  • load a image:
docker load < Name.tar
  • start a docker:
docker run --shm-size=1g --ulimit memlock=-1 --ulimit stack=67108864 --cap-add SYS_PTRACE --rm --gpus all --pid=host --net=host --security-opt apparmor:unconfined -e DISPLAY=$DISPLAY -v /home/temp:/workspace -v /home/pipeline:/data/pipeline -w /data/pipeline_capture -it Name


9. docker compose:
    start all the images:
        docker-compose up -d
        docker-compose up -d --build
        docker-compose -f docker-compose-local.yml -d --build
        (use a specific docker compose file)

    stop all the images:
        docker compose down


10. docker storage analysis:
    docker system df

11. docker clear storage:
    clean all:
        docker system prune
    clean cache:
        docker builder prune
    clean volume:
        docker volume prune
    clean container:
        docker container prune

12. docker logs:
    if i only want to check the last 100 lines of logs since a certain time:
        docker logs -f -t [--since="2018-02-08"] --tail=100 CONTAINER_ID
            -f: 跟踪实时日志
            -t: 显示时间戳
 
    if i only want to check the latest 30min of logs:
        docker logs --since 30m CONTAINER_ID