跳到主要内容

更新应用

原页面

更新源代码

  1. src/static/js/app.js 中修改第 56 行
    - <p className="text-center">No items yet! Add one above!</p>
    + <p className="text-center">You have no todo items yet! Add one above!</p>
  2. 重新构建镜像。
    docker build -t getting-started .
  3. 启动容器。
    ```shell
    docker run -dp 3000:3000 getting-started
    ```
    可能会遇到这样的报错:
docker: Error response from daemon: driver failed programming external connectivity on endpoint laughing_burnell 
(bb242b2ca4d67eba76e79474fb36bb5125708ebdabd7f45c8eaf16caaabde9dd): Bind for 0.0.0.0:3000 failed: port is already allocated.

这是因为我们旧的容器还在运行,而一个特定的端口(这里是 3000 端口)只能被一个进程占用。我们只需要移除旧的容器就能修复这个报错了。

取代旧容器

要移除一个容器,必须先将它停止。

用 CLI 移除一个容器

  1. 通过 docker ps 获取容器的 ID 。
    docker ps
  2. 使用 docker stop 来停止容器。
    docker stop <the-docker-id>
  3. docker rm 来移除镜像。
    docker rm <the-container-id>

可以直接用“force”修饰符来停止并移除一个容器,比如:docker rm -f <the-container-id>

启动更新好的容器

  1. 启动容器。
    docker run -dp 3000:3000 getting-started
  2. 访问 http://localhost:3000