Prepare docker installation for "offline" environment
We're going to deploy our codebase in an environment with no outbound internet access - using docker. However - we do not seem to be able to pre-build the entire thing so we don't have to pull images from any repository. The server is prepared with docker and docker-compose.
We have a docker-compose.yml
file, its a lot longer that this but this is the part that we don't get to work:
node:
container_name: my-node
build: ./docker/node
volumes_from:
- volumes_source
ports:
- "5000:5000"
links:
- mysql
- redis
In /docker/node we have a Dockerfile:
FROM node:latest
EXPOSE 5000
RUN npm install pm2 -g
CMD ["pm2-docker", "/var/www/laravel/socket/socket.js"]
I want to pre-build this so that it wont have to run the npm install pm2 -g
bit - since it wont work. What I have tried is:
- Booted this as a container on a internet connected host
-
docker commit 8671bf3bd1b5 my-node:latest
(8671bf3bd1b5 is container id) docker save -o my-node.docker my-node:latest
docker export 8671bf3bd1b5 > my-node_latest.tar
- Transfered files to offline environment
docker load -i my-node.docker
cat my-node_latest.tar | docker import - my-node:latest
- Remove
build: ./docker/node
from docker-compose.yml in offline environment and replace withimage: my-node:latest
It still tries to pull node:latest and run npm install pm2 -g
though. What are we doing wrong?
yes, you have exported image/container named my-node:latest. But in Dockerfile, it is built from node:latest, which you forget to export. ...