1. 获取镜像
# 查看可用的稳定版本
sudo docker search node
sudo docker pull kkarczmarczyk/node-yarn
sudo docker image ls |grep node
2. 创建数据卷
sudo mkdir -p /share/node/app
3. 启动容器
sudo docker run -it --name nodeapp -v /share/node/app/:/workspace -p 80:80 kkarczmarczyk/node-yarn
# 退出容器(Ctrl + P + Q)
sudo docker start nodeapp
sudo docker restart nodeapp
sudo docker stop nodeapp
sudo docker rm nodeapp
4. 验证
# 进入终端
sudo docker exec -it nodeapp /bin/bash
# 安装vue-cli
yarn global add @vue/cli
# 编译项目
yarn
# 启动项目
yarn serve
# 查看日志
sudo docker logs nodeapp
sudo docker logs -f -t --tail=50 nodeapp
# 查看网络
sudo docker network ls
sudo docker inspect nodeapp