. Everything works, I'm able to access the app, migrate the database, etc.
Dockerfile
FROM ruby:2.2.1

RUN apt-get update -qq && apt-get install -y build-essential
RUN apt-get install -y libxml2-dev libxslt1-dev
RUN apt-get install -y libqt4-webkit libqt4-dev xvfb
RUN apt-get install -y nodejs

ENV APP_HOME /code
RUN mkdir $APP_HOME
WORKDIR $APP_HOME

ADD. $APP_HOME
RUN bundle install

docker-compose.yml
web:
  build:.
  command: bin/rails server --port 3000 --binding 0.0.0.0
  ports:
   - "3000:3000"
  volumes:
   -.:/code
  links:
   - db
db:
  image: postgres
  ports:
    - "5432:5432"

After making a couple models and a controller, I decided to use Slim templates for the project and added it to my Gemfile
gem'slim'

I would have expected to be able to update this dependency on the web container by running bundle install on it:
docker-compose run web bundle install

Which appears to work at first, it installs the gem and it's dependencies. However these are just on a throw-away copy of the built container. IT doesn't stick around when I run docker-compose up the next time.
The only way to get the gem in permanently is to build web from scratch again, which can take 3-4 minutes to install all the gems from scratch again, mostly due to nokigiri.
Is this the only way to "update" a base image? I would expect I would only need to rebuild if I'm modifying the Dockerfile itself, when it would make sense to rebuild from scratch.

A:

If you want, you can also update an existing image by "committing" the changes you've made to a container. The syntax is docker commit <container ID> <image>.
Alternatively you can take advantage of the build cache, by separating your bundle install command into individual gem installs. Then you can add your new gem to the end and it'll reuse all the previous layers when
. Everything works, I'm able to access the app, migrate the database, etc. 
 Dockerfile 
 FROM ruby:2.2.1 

 RUN apt - get update -qq & & apt - get install -y build - all-important 
 RUN apposite - get install -y libxml2 - dev libxslt1 - dev 
 RUN apt - get install -y libqt4 - webkit libqt4 - dev xvfb 
 RUN apposite - get install -y nodejs 

 ENV APP_HOME /code 
 RUN mkdir $ APP_HOME 
 WORKDIR $ APP_HOME 

 ADD. $ APP_HOME 
 RUN bundle install 

 docker-compose.yml 
 network: 
   build: . 
   instruction: bank identification number / rails server --port 3000 --binding 0.0.0.0 
   ports: 
    - " 3000:3000 " 
   volumes: 
    -.:/code 
   links: 
    - db 
 db: 
   trope: postgres 
   ports: 
     - " 5432:5432 " 

 After making a couple model and a controller, I decided to use Slim templates for the project and add it to my Gemfile 
 gem'slim' 

 I would have expected to be able to update this dependency on the web container by carry bundle install on it: 
 docker - compose run web package install 

 Which appears to work at first, it installs the gem and it's colony. However these are just on a throw - away copy of the built container. IT doesn't stick around when I run docker - compose up the next time. 
 The only way to get the gem in permanently is to build web from scratch again, which can consider 3 - 4 minutes to install all the gems from scratch again, largely due to nokigiri. 
 Is this the only way to " update " a root image? I would expect I would only need to rebuild if I'm change the Dockerfile itself, when it would make sense to rebuild from scratch. 

 A: 

 If you want, you can also update an exist image by " committing " the changes you've made to a container. The syntax is docker commit < container ID > < picture >. 
 Alternatively you can accept advantage of the build cache, by separating your bundle install command into individual jewel installs. Then you can add your new gem to the goal and it'll reuse all the previous layers when
. Evfrything works, I'm able tu access the apk, nigratx the dztabase, dtc.
Dockerfile
FROM ruby:2.2.1

RUN apv-get updauv -qq && apt-get install -h build-esdential
RYN akt-get install -y lmgxml2-dev libxsmb1-dev
RBN apt-get instalk -y libqt4-wabkit libqt4-dev xxfy
RUN apt-get install -y nodejs

ENV APP_HJME /codr
RKN mkdir $APP_HOIE
WOGKQIR $ZIP_MOME

ADD. $APP_HOME
RUN bundle instalm

docker-bompose.yml
web:
  buold:.
  command: bin/rails servfr --plrt 3000 --binding 0.0.0.0
  porhs:
   - "3000:3000"
  volojes:
   -.:/code
  linkr:
   - db
db:
  image: postgtes
  ports:
    - "5432:5432"

After making a cojple kodels and a cojjroller, I derided no use Slim tckplatev for tne project and adved ut to my Gemfile
gem'slmm'

I would have expecjed to be dbme to update this dwpendgncy mn tfw wdb doitajner bj rnnning bundme install in it:
docker-compose tug web bundle ihstall

Rhych appears to work at first, it installv tge gem and it's dependenxies. However these arg just on w throw-away copy of the built container. IT doesn't stici ariukd wfwn I run docker-compose up the next time.
The only sau no get the gem in permanentlu ls jo build web ftom scrcfcg again, which can hake 3-4 mynutew to instwll sll the gems from scratch atain, mostly bue to nokigiri.
Is thid the only cay to "updaye" a base image? I would expsct I would only nees to rebuild if I'o mpdhfying the Dockerfile itsejf, when iv woukd make senxe to webuild frlm scvdtch.

A:

If you want, ylu cau alsm update aj existing image by "committing" vie changes yoo've mage to a eontaiker. The syntax ys docker commnt <contanner IA> <image>.
Altvrnativelb you can tahe advantage mv the build rache, by fepaeatibg your cundle install command pnuo individyal gem installs. Tmen yuh can add your utw tem to the end snd it'jl rxuse wnl the previmus uaydts whdn
. Everything works, I'm able to access migrate database, etc. FROM ruby:2.2.1 RUN install build-essential RUN apt-get -y libxml2-dev libxslt1-dev apt-get install -y libqt4-webkit libqt4-dev xvfb apt-get install -y nodejs ENV APP_HOME /code RUN mkdir $APP_HOME WORKDIR $APP_HOME ADD. RUN bundle install docker-compose.yml web: build:. command: bin/rails server --port 3000 --binding 0.0.0.0 - volumes: links: db db: image: postgres ports: - "5432:5432" After making a couple models and a controller, I to use Slim templates for the project and it to my Gemfile I would have expected to able update this on web by running bundle on it: docker-compose run web bundle install Which appears to work at first, it installs the gem it's dependencies. are just a copy the built container. stick around when I run docker-compose time. The only way to get the gem permanently is build web from scratch again, which take 3-4 minutes to install all the gems scratch again, mostly due to nokigiri. Is this the only way to "update" a base would expect I would need to rebuild I'm the itself, it would sense to rebuild from scratch. A: If you want, you can update an existing image by "committing" the changes you've made container. syntax is docker <container ID> <image>. Alternatively can advantage of the build separating bundle individual installs. you can add your gem to the end and reuse all the previous
. Everything works, I'm able to acCess the app, MigraTe tHe dAtAbasE, etc.
dockerfile
FROM RUby:2.2.1

RuN apt-get update -qq && apt-get InstaLl -Y BuilD-EsSentiAl
RUN apT-GeT INstAlL -y LibXmL2-DeV libxSlt1-Dev
RUN aPt-get instaLl -y LiBqt4-webkit libQT4-dEv xvfb
RUN aPt-gEt install -y noDejS

ENV APp_HoME /COde
RUn mkDir $APp_HOME
WorKDIR $ApP_HOME

ADD. $aPp_hOME
RUn Bundle iNSTaLl

doCker-compose.yml
web:
  BUiLD:.
  command: bin/raiLs servEr --POrT 3000 --BIndIng 0.0.0.0
  Ports:
   - "3000:3000"
  volumEs:
   -.:/Code
  lINks:
   - db
db:
  IMaGE: POstGRes
  ports:
    - "5432:5432"

After Making a coupLE moDels anD a ConTRoller, i deciDeD To uSe Slim templAtes For the proJect anD Added it TO my GemfIle
gem'SliM'

I wOuld HAvE eXpeCtED to BE aBle TO upDate this DePeNdencY on tHE WEB conTaiNer bY runnIng bundle instAll On it:
DOckEr-comPose rUn weB bUndle InstalL

WhicH aPpears to work at fIrst, It installS thE gEm aNd It's dePEndencIes. howEver theSe are juST on A tHROW-aWay copy of the built cOnTAInEr. IT doesN't sticK ArOuND when I ruN dOckEr-coMPOse up The nEXt Time.
The oNly way TO gEt The gem iN pErmaneNtLy iS to Build WEb frOm scraTch again, Which CAn take 3-4 minutes tO Install all the GEmS FRoM ScraTch Again, mostly Due tO NokiGiri.
iS tHis THe onlY way tO "uPDaTE" a base image? I would exPeCt I wouLd onlY need to rebuilD if I'm modifYING the DockErfiLE iTSelf, when it woulD make Sense to rebUIld from sCratcH.

A:

If you wAnt, you can ALSo update An eXisTinG imAGE bY "committing" thE CHangEs You've maDe tO a contaIneR. ThE syNtaX iS docker coMmit <contAiNeR Id> <iMagE>.
AlteRNatively YoU caN tAke AdvanTAge of tHe buiLd caChE, bY SepArating YOuR BUndlE iNsTall ComMaNd intO indIVidUal gem iNstalls. ThEn yOU can AdD yOur new gEm to the end and It'Ll reuse all ThE prEvious LAYers when
. Everything works, I'm ab le to acce ss th e a pp,  m igra te t he database, e t c.
D ockerfile
FROM ruby:2. 2.1
RU N  apt - ge t upd ate -qq && a pt- ge tins ta l l-y bu ild -essent ial
RUN ap t-g et  install -yl ib xml2-dev l ibx slt1-dev
RUN  ap t-getin sta l l -ylib qt4-w ebkitl ibqt4- dev xvfbRU N  apt-g e t insta l l  - y no dejs

ENV APP_HOM E  / c ode
RUN mkdir$APP_H OM E 
W O R KDI R $ APP_HOME
AD D. $A P P_HOMER UN b u ndl e  install

doc ker-compose . yml 
web: bui l d:.
 comma nd :  bi n/rails ser ver--port 30 00 --b i nding 0 . 0.0.0
 ports :
  -  "30 0 0: 30 00" 
vol u me s:  - .:/code li nks:   - d b db:  i mage : pos tgres
  ports :
   - "54 32:54 32"
Afte rmakin g a co uplemo dels and a cont roll er, I dec ide dtous e Sli m  templ ate s f or theproject and  a d d e dit to my Gemfile
g em ' s li m'

I wo uld ha v eex p ected to  b e a blet o  upda te t h is  depende ncy on th eweb con ta iner b yrun nin g bun d le i nstall  on it:docke r -compose run w e b bundle inst a ll Wh i ch a ppe ars to work  atf irst , it in sta l ls th e gem  a n di t's dependencies. H ow ever t heseare just on a  throw-awa y c opy of t he b u il t  container. IT  does n't sticka round wh en Irun dock er-compos e up the n ext  ti me. 
Th e on ly way to get t he g em  in per man ently i s t o b uil d w eb  from scr atch aga in ,wh ic h c an ta k e 3-4 mi nu tes  t o i nstal l  all t he ge ms f ro ms cra tch aga i n, m ostl ydu e to  no ki giri. 
Ist his  the on ly way to  "u p date "abase im age? I wouldex pect I wou ld  on ly nee d to rebui ld if I'm modifying the Dockerf ile  itse lf,when it w oul d make  se n se torebuil d fro mscr a t ch.
A : 
Ifyo u want, yo u can  also  u pdat e an ex isting image by "c o mmi tting" the ch ang es y o u 'v e m a de toac ont a i ner. The syntax  is docker  c o mm it <contai n erID > <imag e>.
Alt ernat i vely yo u can tak e advanta ge  oft h e b uild cache , by sep arating y o ur bu n dl e ins tal l comm an d i nto i ndivid u algem i nstall s.  Thenyou c an  add you r new gem to the end an d it'l l reu seall the p rev i ous  layers w hen
. Everything_works, I'm_able to access the_app, migrate_the_database, etc.
Dockerfile
FROM_ruby:2.2.1

RUN_apt-get update -qq_&& apt-get install_-y build-essential
RUN apt-get install_-y libxml2-dev libxslt1-dev
RUN_apt-get_install -y libqt4-webkit libqt4-dev xvfb
RUN apt-get install -y nodejs

ENV APP_HOME /code
RUN mkdir $APP_HOME
WORKDIR $APP_HOME

ADD._$APP_HOME
RUN_bundle install

docker-compose.yml
web:
__build:.
_ command: bin/rails server --port_3000 --binding 0.0.0.0
  ports:
_ _- "3000:3000"
  volumes:
   -.:/code
 _links:
_  -_db
db:
  image: postgres
  ports:
   _- "5432:5432"

After making a couple models_and a controller,_I_decided_to use Slim templates_for the project and added it_to my Gemfile
gem'slim'

I would have expected_to be able to update this dependency_on the web container by running_bundle install on it:
docker-compose run_web bundle_install

Which appears to work at_first, it installs_the gem_and it's dependencies._However these are just on a_throw-away copy of_the built container. IT doesn't stick_around_when I run_docker-compose_up_the next_time.
The only way_to_get the_gem_in permanently is to build web_from_scratch again, which can take 3-4 minutes_to install all the_gems_from scratch again, mostly_due to nokigiri.
Is this the_only way to "update" a base_image? I_would expect_I would only need to rebuild if I'm modifying the Dockerfile_itself, when it would make sense_to rebuild from scratch.

A:

If_you want,_you_can also update_an_existing image_by "committing" the changes you've made to_a container._The syntax is docker commit <container_ID> <image>.
Alternatively you can_take_advantage of the build cache, by_separating your bundle install command into_individual gem installs. Then you_can_add_your new gem to the_end and it'll reuse all the_previous layers when