JayFate / note

MIT License
0 stars 0 forks source link

docker #1

Open JayFate opened 1 year ago

JayFate commented 1 year ago

你也可以查看所有的容器,包括没有在运行状态的容器,使用 docker ps -a 命令

JayFate commented 1 year ago
# 停止容器  2139   2139
docker stop 2139 1e2a

# 删除容器
docker rm c3a2 b6d4 3363

# 停止并删除所有的容器
docker ps -aq | xargs docker stop | xargs docker rm

# 停止并删除所有的正在运行的容器
docker ps -q | xargs docker stop | xargs docker rm

# 进入容器
docker exec -it dda5 bash
JayFate commented 1 year ago

使用 docker build 来构建 web 应用

https://docker-training-labs.readthedocs.io/en/latest/01-getting-started/docker-machine-commands.html

docker-comopse up, docker-comopse start, docker-comopse restart 的区别 https://blog.csdn.net/wangooo/article/details/109362673 https://stackoverflow.com/questions/33715499/what-is-the-difference-between-docker-compose-up-and-docker-compose-start

JayFate commented 1 year ago

一个可以直接使用的 docker-compose.yml

version: '3.7'

volumes:
  wp-data:
networks:
  wp-back:

services:

  db:
    image: mysql:5.7
    volumes:
      - wp-data:/var/lib/mysql
    environment:
       MYSQL_ROOT_PASSWORD: rootPassword
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wp-user
       MYSQL_PASSWORD: wp-pass
    ports:
      - 8889:3306
    networks:
      - wp-back

  phpmyadmin:
    depends_on:
      - db
    image: phpmyadmin/phpmyadmin
    environment:
      PMA_HOST: db
      MYSQL_USER: wp-user
      MYSQL_PASSWORD: wp-pass
      MYSQL_ROOT_PASSWORD: rootPassword
    ports:
      - 3001:80
    networks:
      - wp-back

  wordpress:
    depends_on:
      - db
    image: wordpress:latest
    ports:
      - 8888:80
      - 443:443
    environment:
       WORDPRESS_DB_HOST: db
       WORDPRESS_DB_USER: wp-user
       WORDPRESS_DB_PASSWORD: wp-pass
    volumes:
      - ./wordpress-files:/var/www/html
    container_name: wordpress-site
    networks:
      - wp-back
JayFate commented 1 year ago

用Docker搭建Python环境

https://www.jianshu.com/p/18108c28ec1b https://blog.csdn.net/m0_37605642/article/details/124330514

轻松在 Docker 容器中运行 MySQL

https://www.linuxmi.com/docker-run-mysql.html

docker 设置国内镜像加速

{
  "builder": {
    "gc": {
      "defaultKeepStorage": "20GB",
      "enabled": true
    }
  },
  "registry-mirrors": [
    "https://docker.mirrors.ustc.edu.cn",
    "https://registry.docker-cn.com",
    "http://hub-mirror.c.163.com"
  ],
  "experimental": false,
  "features": {
    "buildkit": true
  }
}
JayFate commented 1 year ago

运行以下命令启动容器,并将本地的docker-training目录内容挂接到容器内的docker-training目录中。

docker run -it -v d:/docker-training:/docker-training ubuntu /bin/bash
docker run --rm ba-208
# --rm 在容器退出时就能够自动清理容器内部的文件系统,--rm选项不能与-d同时使用
docker logs -f 34f7
# 获取容器日志并实时输出

使用google/cAdvisor对容器主机和应用进行监控

https://docker-training-labs.readthedocs.io/en/latest/03-common-challenges/docker-monitor.html

JayFate commented 1 year ago

docker-compose 示例 docker-file 示例

10分钟学会使用 Docker 部署 Ghost 博客

https://www.linuxmi.com/docker-bushu-ghost.html https://computingforgeeks.com/how-to-run-ghost-cms-in-docker-containers/ https://draft.dev/learn/running-ghost-on-docker-for-your-developer-blog

给前端写的Docker+Node+Nginx+Mongo的本地开发+部署实战

https://juejin.cn/post/6844904004296638478

Docker 搭建你的第一个 Node 项目到服务器(完整版)

https://juejin.cn/post/6844904035053486087

JayFate commented 1 year ago

VIM: 解决vi/vim中粘贴时行首出现很多缩进和空格的问题

解决办法:
1,在拷贝前输入:set paste (这样的话,vim就不会启动自动缩进,而只是纯拷贝粘贴)
2,拷贝完成之后,输入:set nopaste (关闭paste)
JayFate commented 1 year ago

vscode同时编辑多处文字 批量替换编辑内容 https://blog.csdn.net/woshidamimi0/article/details/84560982

JayFate commented 1 year ago

https://blog.csdn.net/weixin_43246170/article/details/127985646?spm=1001.2101.3001.6650.3&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EYuanLiJiHua%7EPosition-3-127985646-blog-110009106.pc_relevant_recovery_v2&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EYuanLiJiHua%7EPosition-3-127985646-blog-110009106.pc_relevant_recovery_v2&utm_relevant_index=5