講者:土豆
時間:2020/10/25
sudo apt-get update && sudo apt-get install -y vim python3-pip curl git docker-compose
pip3 install --upgrade pip
git clone -b 2.0 https://github.com/QingdaoU/OnlineJudgeDeploy.git && cd OnlineJudgeDeploy
docker-compose up -d
user: user
password: user1234
sudo apt-get update # 更新套件庫
curl -fsSL https://get.docker.com -o get-docker.sh # 取得官方提供之安裝腳本
sudo sh get-docker.sh # 執行腳本
sudo usermod -aG docker user # 將user加入docker群組,沒加入的話執行docker指令需加上sudo
# 重新登入,讓權限生效
Docker Image
Docker Container
docker run -v [host_volume]:[container_volume] -p [host_port]:[container_port] -it [image_name] /bin/bash
docker pull python:latest
docker run python:latest
mkdir django
cd django
nano Dockerfile
# Dockerfile 內容
FROM python:latest
MAINTAINER sam
RUN apt-get update
RUN apt-get install nano
RUN pip install django
docker build . -t="sam/django"
docker stop [container id]
docker start [container id]
啟動container
停止container
docker ps
確認正在運行的container
docker ps -a
確認正在運行與已停止的container
docker exec -it [container id] [command]
docker attach [container id]
# 如果要出來的話按下鍵盤的 ctrl + p 以及 ctrl + q
回到container中
使用container執行某個指令
docker image rm [image_name]
docker images
列出現有image
刪除某個image
docker container rm [container_id]
刪除某個container
sudo apt-get update && sudo apt-get install -y vim python3-pip curl git docker-compose
pip3 install --upgrade pip
git clone -b 2.0 https://github.com/QingdaoU/OnlineJudgeDeploy.git && cd OnlineJudgeDeploy
docker-compose up -d