Hurricane Development
Hurricane Development

Reputation: 2464

How to share apt-package across Docker containers

I want to use docker to help me stay organized with developing and deploying package/systems using ROS (Robot Operating System).

I want to have multiple containers/images for various pieces of software, and a single image that has all of the ROS dependencies. How can I have one container use the apt-packaged from my dependency master container?

For example, I may have the following containers:

How do I use apt packages from container in another container without reinstalling them on each container each time?

Upvotes: 1

Views: 1917

Answers (1)

Farhad Farahi
Farhad Farahi

Reputation: 39237

You can create your own images that serve you as base images using Dockerfiles.

Example:

mkdir ROSDocker
cd ROSDocker
vim Dockerfile-base

FROM debian:stretch-slim
RUN apt-get install dep1 dep2 depn

sudo docker build -t yourusername/ros-base:0.1 -f Dockerfile-base . 

After the build is complete you can create another docker file from this base image.

FROM yourusername/ros-base:0.1
RUN apt-get install dep1 dep2 depn

Now build the second images:

sudo docker build -t yourusername/mymoveApplication:0.1 -f Dockerfile-base .

Now you have an image for your move application, each container that you run from this image will have all the dependencies installed.

You can have docker image repository for managing your built images and sharing between people/environments.

This example can be expanded multiple times.

Upvotes: 3

Related Questions