12示例 Dockerfile

  • 2019 年 10 月 4 日
  • 筆記

示例 Dockerfile 犯了几乎所有的错(当然我是故意的)。接下来,我会一步步优化它。假设我们需要使用 Docker 运行一个 Node.js 应用,下面就是它的 Dockerfile(CMD 指令太复杂了,所以我简化了,它是错误的,仅供参考)。

FROM ubuntu    ADD . /app    RUN apt-get update    RUN apt-get upgrade -y    RUN apt-get install -y nodejs ssh mysql    RUN cd /app && npm install    # this should start three processes, mysql and ssh    # in the background and node app in foreground