docker部署code-server的方法

拉取鏡像

# docker pull codercom/code-server
# docker images
REPOSITORY             TAG       IMAGE ID       CREATED       SIZE
codercom/code-server   latest    f3ac734fcec8   12 days ago   802MB

創建掛載目錄

# CODE=/home/docker/code
# mkdir $CODE && cd $CODE

配置文件

方法1:從容器中導出

啟動一個容器:-u 表示使用root用戶運行

# docker run -d -u root -p 8088:8080 --name code-server -v $CODE:/home/code codercom/code-server
# docker ps
CONTAINER ID   IMAGE                  COMMAND                  CREATED       STATUS       PORTS                                       NAMES
97707c93cb41   codercom/code-server   "/usr/bin/entrypoint…"   3 hours ago   Up 3 hours   0.0.0.0:8088->8080/tcp, :::8088->8080/tcp   code-server

拉出配置文件:

# docker cp code-server:/root/.config/code-server/config.yaml $CODE/
# cat $CODE/config.yaml
bind-addr: 127.0.0.1:8080
auth: password
password: 59bd4df2841fbc77d67f674f
cert: false

改個密碼:123456

方法2:直接新建配置文件[

# vim $CODE/config.yaml
bind-addr: 127.0.0.1:8080
auth: password
password: 123456
cert: false

啟動服務

# docker stop code-server && docker rm code-server
# docker run -d -u root \
  -p 8088:8080 \
  --name code-server \
  -v $CODE/config.yaml:/root/.config/code-server/config.yaml \
  -v $CODE:/home/code \
  codercom/code-server

訪問例如 http://192.168.0.206:8088/

到此這篇關於docker部署code-server的文章就介紹到這瞭,更多相關docker部署code-server內容請搜索WalkonNet以前的文章或繼續瀏覽下面的相關文章希望大傢以後多多支持WalkonNet!

推薦閱讀: