19π
I got the answer from the docker contributor Brian Goff:
docker run -d --name mydb postgres
docker run --rm --link mydb:db myrailsapp rake db:migrate
docker run -d --name myapp --link mydb:db myrailsapp
This is going to fire up postgres.
Fire up a container which does the db migration and immediately exits and removes itself.
Fires up the rails app.
Think of the build process like compiling an application. You donβt seed data into a database as part of the compilation phase.
11π
True, but docker build
does accept the --network
option.
You can put your prerequisite containers on a named / custom network, e.g.:
docker network create whatever
docker run --network whatever --name postgres [etc.] someproject/develop
Then build on that network:
docker build --network whatever [etc.]
Works well.
- [Django]-Creating and saving foreign key objects using a SlugRelatedField
- [Django]-Django can't find new sqlite version? (SQLite 3.8.3 or later is required (found 3.7.17))
- [Django]-Django REST Framework upload image: "The submitted data was not a file"
4π
You can not do this. You could either build a child image of postgres, or update the database every time you start the container.
- [Django]-Python Django: You're using the staticfiles app without having set the STATIC_ROOT setting
- [Django]-How to edit django-allauth default templates?
- [Django]-Django vs PHP+framework
2π
I had a similar issue. I wanted to speed up image builds with the help of apt-cacher
. It runs in its own container and somehow other images, which I built, had to communicate with it.
The solution was to publish apt-cacher
port on all interfaces. This includes e.g. docker0
, which is available to intermediate containers spawned during image build.
Example Dockerfile
:
FROM debian:8
RUN ping -c 2 172.17.0.1
And this is how it builds:
$ docker build - <dock
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM debian:8
---> 47af6ca8a14a
Step 2 : RUN ping -c 2 172.17.0.1
---> Running in 4f56ce7c7b63
PING 172.17.0.1 (172.17.0.1): 56 data bytes
64 bytes from 172.17.0.1: icmp_seq=0 ttl=64 time=0.117 ms
64 bytes from 172.17.0.1: icmp_seq=1 ttl=64 time=0.130 ms
--- 172.17.0.1 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max/stddev = 0.117/0.123/0.130/0.000 ms
---> 5c73a36a0a6a
Removing intermediate container 4f56ce7c7b63
- [Django]-How do I use an UpdateView to update a Django Model?
- [Django]-Django β User.DoesNotExist does not exist?
- [Django]-TypeError: login() takes 1 positional argument but 2 were given