學習進度

感覺實用的資料

監控 docker 目前使用資源

用Docker搭建Laravel开发环境

Docker — 从入门到实践

精简Docker镜像的五种通用方法

Docker tutorial PART I

Docker tutorial PART II

Laravel + Docker 輕鬆上手

站在 Docker 的肩膀上,部署任何語言的 Web 應用到 Heroku

使用laradock來部屬laravel

100 行 shell 写个 Docker

用docker image 在heroku部署網站

如何將前端網站打包成 Docker Image

其實沒有那麼難 — Docker 系列

Docker实用命令手册

實用指令

使用 node 在當前目錄建立 vue 專案

docker run --rm -v "${PWD}:/app" -w "/app" -u node -it node:latest sh -c "yarn add global @vue/cli && yarn exec vue create ."

另一種寫法,會新建立一個專案目錄

docker run --rm -u 1000:1000 -v $PWD:/app -w /app -u node -it node:latest sh -c "npm init vue@latest"

在本地端開啟 vue 專案

docker run --rm -p 8080:8080 -v "${PWD}:/app" -w "/app" -u node -it node:latest sh -c "npm run serve"

使用 vite run 起來的

docker run --rm -p 5173:5173 -u 1000:1000 -v $PWD:/app -w /app -u node -it node:latest npm run dev -- --host

使用 docker 在當前路徑下下載 laravel 專案

docker run --rm -v $PWD:/app -w /app composer create-project laravel/laravel

使用紀錄

  • 在laradock資料夾下
    • docker-compose up -d nginx mysql
    • docker-compose down
  • 建議laravel 專案自己另外下載,不要用docker-compose 的bash
    • composer create-project laravel/laravel prefer-dist projName "7.*"
      • 不指定好像會是最新的
  • nginx\sites\xxx.conf
    • 中的root 要設定成/var/www/public
    • 預設會設定成/var/www/laravel/public
  • docker container run rm -v ${PWD}:/app/ php:7.4-cli php /app/test.php
    • 使用php 在當前路徑下使用php7.4 版本找test.php 執行
    • 參考網站
  • docker container run rm -v ${PWD}:/app/ composer composer create-project prefer-dist laravel/laravel /app/direct-docker-test
    • 使用composer 在當前路徑下安裝名為direct-docker-test 的laravel 專案
  • docker container run rm -u=1000:1000 -v ${PWD}:/app/ composer composer create-project prefer-dist laravel/laravel:^7.4 /app/echo
    • 安裝7.4版本 laravel
  • docker container run rm -v ${PWD}:/app/ composer composer create-project prefer-dist laravel/laravel=7.* /app/mongoArrange
    • 指定 laravel 版本
    • 使用 mongo 的坑,安裝不了以下兩個套件
      • composer require mongodb/mongodb ignore-platform-reqs
      • composer require jenssegers/mongodb ignore-platform-reqs

20211012 全新下載使用版本

  • 開個資料夾
  • cd 進該資料夾
  • 下載需要的laravel 版本
    • composer create-project laravel/laravel prefer-dist projName "可選不填則為最新版"
  • 下載laradock
    • git clone https://github.com/Laradock/laradock.git Laradock
    • 複製.env 檔案
      • from
        Image Not Showing Possible Reasons
        • The image file may be corrupted
        • The server hosting the image is unavailable
        • The image path is incorrect
        • The image format is not supported
        Learn More →
      • to
        Image Not Showing Possible Reasons
        • The image file may be corrupted
        • The server hosting the image is unavailable
        • The image path is incorrect
        • The image format is not supported
        Learn More →
    • 修改紅框兩處,選擇跟laradock 資料夾同一層的laravel 專案 & 放資料的data 資料夾
      • Image Not Showing Possible Reasons
        • The image file may be corrupted
        • The server hosting the image is unavailable
        • The image path is incorrect
        • The image format is not supported
        Learn More →
    • 再到nginx 資料夾複製.conf檔案
      • Image Not Showing Possible Reasons
        • The image file may be corrupted
        • The server hosting the image is unavailable
        • The image path is incorrect
        • The image format is not supported
        Learn More →
    • 這個中間的laravel 要記得刪掉
      • Image Not Showing Possible Reasons
        • The image file may be corrupted
        • The server hosting the image is unavailable
        • The image path is incorrect
        • The image format is not supported
        Learn More →

資料夾結構路徑圖

  • Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More →

20211013

20211115

20211204

20211207

20211229

20211230

20230106

20230108

  • 當 docker run 的時候用 -v 掛載時 $PWD:/app 後面的 /app 可在 image build 時設定 WORKDIR /app 對應

20230126

使用 docker 在當前路徑下下載 laravel 專案

docker run --rm -v $PWD:/app -w /app composer create-project laravel/laravel

20230203

稍微整理一下此份筆記紀錄

  • 整理成更加利用 HackMD 的資料結構

20231209

docker-compose 的多 yaml 檔案設定 : COMPOSE_FILE

20240124

  • build image user 較安全的作法
ARG RUST_VERSION=1.75.0

FROM rust:${RUST_VERSION}-slim-bookworm AS builder
WORKDIR /app
COPY . .
RUN \
  --mount=type=cache,target=/app/target/ \
  --mount=type=cache,target=/usr/local/cargo/registry/ \
  cargo build --release && \
  cp ./target/release/hello-rs /

FROM debian:bookworm-slim AS final
RUN adduser \
  --disabled-password \
  --gecos "" \
  --home "/nonexistent" \
  --shell "/sbin/nologin" \
  --no-create-home \
  --uid "10001" \
  appuser
COPY --from=builder /hello-rs /usr/local/bin
RUN chown appuser /usr/local/bin/hello-rs
COPY --from=builder /app/config /opt/hello-rs/config
RUN chown -R appuser /opt/hello-rs
USER appuser
ENV RUST_LOG="hello_rs=debug,info"
WORKDIR /opt/hello-rs
ENTRYPOINT ["hello-rs"]
EXPOSE 8080/tcp

20240126

  • 遇到 OS can't spawn worker thread: Operation not permitted (os error 1) 的錯誤
    • 本機 build 後且 up service 成功,結果上 vps 時 service 建立失敗
    • 使用 logs 看到以上錯誤
    • 本來以為是不是 VPS 只有單核,然後使用 rust 使用多核功能造成的錯誤(結果不是)
    • 看了其他類似的案例後懷疑是 docker 版本過舊造成
    • 看了很多升級 docker 版本的作法,都很麻煩
    • 最後在這看到較簡易的方式,將 docker & docker-compose 都更新版本後就沒問題了
    • docker

    image

    • docker-compose

    image

20240131

docker run -ti --rm  -v /var/run/docker.sock:/var/run/docker.sock wagoodman/dive <要檢查的 image>