在更新dockerfile之后重新创建容器

拉兹

我有dev.Dockerfile一个docker-compose.yml文件。运行时docker-compose up,即使更新了,它也会运行旧容器dev.Dockerfile如何更新容器?运行后有没有办法更新容器docker-compose up这是我的dev.Dockerfile

FROM ruby:2.3.1
MAINTAINER Abraham Kuri <[email protected]>

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

RUN set -ex \
  && curl -sL "https://deb.nodesource.com/setup_6.x" | bash - \
  && apt-get -y install nodejs \
  && npm install -g bower

RUN gem install bundler -v 1.11.2 --no-ri --no-rdoc

ENV PATH=/usr/src/app/bin:$PATH LANG=C.UTF-8

ADD Gemfile* /usr/src/app/

# Run dependencies install commands
RUN bundle

docker-compose.yml

version: '2'

volumes:
  postgres-data:
    driver: local
  redis-data:       # The redis data store volume
    driver: local
  gems:
    driver: local

services:
  redis:
    image: redis:3.0.7
    ports:
      # We'll bind our host's port 6379 to redis's port 6379, so we can use
      # any explorer to read the database:
      - 6379:6379
    volumes:
      # We'll store the redis data in the 'redis-data' volume we defined:
      - redis-data:/var/lib/redis
    command: redis-server --appendonly yes
  db:
    image: postgres:9.5.1
    ports:
      # We'll bind our host's port 5432 to postgres's port 5432, so we can use
      # our database IDEs with it:
      - 5432:5432
    volumes:
      # We'll store the postgres data in the 'postgres-data' volume we defined:
      - postgres-data:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: P4Ssw0rD!

  # The job processor container - we'll use this as a base for the rest of the
  # containers:
  jobs: &app
    # Specify the directory from where all commands sent to the container will be
    # issued to where the code is mounted:
    image: catarse/catarse:development
    command: bundle exec sidekiq -c 1 -q default
    working_dir: /usr/src/app
    build:
      context: .
      dockerfile: dev.Dockerfile

    volumes:
      # Mount our app code directory (".") into our app containers at the
      # "/usr/src/app" folder:
      - .:/usr/src/app

      # Mount the 'gems' volume on the folder that stores bundled gems:
      - gems:/usr/local/bundle

    # Keep the stdin open, so we can attach to our app container's process
    # and do things such as byebug, etc:
    stdin_open: true

    # Enable sending signals (CTRL+C, CTRL+P + CTRL+Q) into the container:
    tty: true

    # Link to our postgres and redis containers, so they can be visible from our
    # app containers:
    depends_on:
      # We'll include a link to the 'db' (postgres) container, making it
      # visible from the container using the 'db' hostname:
      - db
      - redis

    # Specify environment variables available for our app containers. We'll leave
    # a YML anchor in case we need to override or add more variables if needed on
    # each app container:
    environment: &app_environment
      LANG: 'C.UTF-8'

      # We'll set the DATABASE_URL environment variable for the app to connect
      # to our postgres container - no need to use a 'config/database.yml' file.
      DATABASE_URL: postgres://postgres:P4Ssw0rD!@db:5432/docker_rails_dev?pool=25&encoding=unicode&schema_search_path=public,partitioning
      REDIS_URL: redis://redis:6379

      # We'll set the RAILS_ENV and RACK_ENV environment variables to
      # 'development', so our app containers will start in 'development' mode
      # on this compose project:
      RAILS_ENV: development
      RACK_ENV: development

    # We'll specify a dotenv file for docker-compose to load more environment
    # variables into our app containers. This dotenv file would normally contain
    # sensitive data (API keys & secrets, etc) which SHOULD NOT be committed into
    # Git.
    # Keep in mind that any changes in this file will require a container restart
    # in order to be available on the app containers:
    env_file:
      - dev.env
  web:
    <<: *app
    command: rails server -b 0.0.0.0 -p 3000 -P /tmp/rails2.pid
    ports:
      - 3000:3000
       # App Guard: Keeps running tests on a separate process:
  test:
    <<: *app # We copy from &app, and override:
    environment:
      <<: *app_environment
      # Override the app environment for this container:
      DATABASE_URL: postgres://postgres:P4Ssw0rD!@db:5432/docker_rails_test?pool=25&encoding=unicode&schema_search_path=public,partitioning
      RACK_ENV: test
      RAILS_ENV: test
      SECRET_KEY_BASE_TEST: "600bac98dabba98b903ce4c4d25e48f34920e09f43d3ff61a1005e0f500d5a0e38e25f70ef78e0a8b5475d4ff21cc553e7c07f6565f1c8773165350345fbbc56"
德里克·贝利(Derick Bailey)

运行docker-compose build以强制重新构建组成文件的容器。https://docs.docker.com/compose/reference/build/

您还docker-compose down可以解构组合的设置:https : //docs.docker.com/compose/reference/down/-然后docker-compose up再进行一次。

也可以手动删除容器和图像,然后docker-compose up再次运行

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

更新/重新创建JList

来自分类Dev

notifyDataSetChanged之后,FragmentStateAdapter不重新创建currentFragment

来自分类Dev

在dispose()调用之后重新创建JinternalFrame对象

来自分类Dev

Docker Compose:避免重新创建数据容器

来自分类Dev

IoTEdge 有时会重新创建容器

来自分类Dev

Terraform-ELB尝试重新创建而不是更新

来自分类Dev

更新后不要重新创建存储库

来自分类Dev

重新创建序列

来自分类Dev

重新创建已创建的片段?

来自分类Dev

Rails和postgres,在删除表之后重新创建表

来自分类Dev

在重新创建父片段之后获得对子片段的引用

来自分类Dev

在删除索引并重新创建索引之后是否需要收集统计信息?

来自分类Dev

在重新创建父片段之后获得对子片段的引用

来自分类Dev

在一些AJAX请求之后重新创建了ViewScoped CDI bean

来自分类Dev

Mosby MVP-在onDestroyView()之后如何重新创建Fragment的状态?

来自分类Dev

是否可以在 close() 之后重新创建 Java BufferedReader 对象

来自分类Dev

无法手动重新创建Unity容器控制的对象(EF dbcontext)

来自分类Dev

vim unite插件重新创建

来自分类Dev

活动重新创建并闪烁

来自分类Dev

在Rails中重新创建表

来自分类Dev

无法重新创建mysql用户

来自分类Dev

载波重新创建版本

来自分类Dev

温莎城堡重新创建实例

来自分类Dev

防止重新创建或覆盖文件

来自分类Dev

定期重新创建对象

来自分类Dev

如何重新创建以前的活动?

来自分类Dev

ngRepeat继续重新创建

来自分类Dev

如何重新创建片段?

来自分类Dev

JavaScript重新创建元素