Do the devices download the full image on each update?

I just realized that my docker image file is almost 900MB. Does that mean that on each update, each device will have to download that full size, or is there some caching?

Thank you!

Hey @hecontreraso. There is indeed caching involved. By default docker will cache layers that are the same. A layer in docker terminology is each discrete command in the dockerfile, for example each RUN, COPY, etc will create a new layer.

In we have also implemented a delta mechanism which does a binary diff between the currently image and the one that was just built, this often results in smaller downloads over the wire to the device. This feature can be enabled by setting a device config environment variable in your dashboard called RESIN_SUPERVISOR_DELTA and set it to a value of 1.

Finally, if you post your Dockerfile here, I am sure some of the community can help you reduce the size. We also have some documentation on build size optimization here: and there is also a new feature called multi-staged builds which can make very very small images, you can read about that here:

1 Like

Thank you, Shaun, for your quick response (Sorry if I ask too many questions)
I indeed applied the optimizations described in the first link. Now my Dockerfile seems much better and the build time was reduced. I have not been able to run my application with multi-stage docker, but still trying to. Here is my dockerfile:

FROM arm32v7/ubuntu AS buildstep

# Add ROS sources and install ros-base
RUN sh -c 'echo "deb xenial main" > /etc/apt/sources.list.d/ros-latest.list'
RUN apt-key adv --keyserver hkp:// --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116

# Install packages
RUN apt-get update && apt-get install -y ros-kinetic-ros-base \
    python-rosinstall \
    python-rosinstall-generator \
    python-wstool \
    build-essential \
    ros-kinetic-mavros \
    ros-kinetic-mavros-extras \

# Remove package lists to free up space
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Initialize rosdep
RUN rosdep init && rosdep update

# Creating workspace for katkin
RUN mkdir -p /catkin_ws
RUN mkdir -p /catkin_ws/src
WORKDIR /catkin_ws

# Copy and execute ROS code
COPY ros /catkin_ws/src
RUN /bin/bash -c "source /opt/ros/kinetic/setup.bash; catkin_make --pkg web_client"
RUN /bin/bash -c "source /opt/ros/kinetic/setup.bash; catkin_make --pkg rover_teleop"

# Copy scripts
COPY raspiConfigs/Launch/kiwiBot.launch /usr/src/app/
COPY /usr/src/app/
COPY /usr/src/app/

# This is the runtime container that will end up running on the device.
#FROM arm32v7/ubuntu

# Copy our node_modules into our deployable container context.
#COPY --from=buildstep /catkin_ws /catkin_ws
#COPY --from=buildstep /opt/ros/kinetic /opt/ros/kinetic
#COPY --from=buildstep /usr/src/app /usr/src/app

# Start the application
CMD ["bash", "/usr/src/app/"]

@hecontreraso does it not build, or does it not run when it gets to the device? Do you have a repo somewhere on github that I could look at?

The dockerfile does build and run successfully. When I uncomment the line related to multi-stage build, it still builds but doesn’t work anymore.
Sure, I can give you access to my repo, just give me your bitbucket username or email :slight_smile:

I think the main thing is that your final image does not have all your dependencies?

The build side has to have all the build time dependencies, but for the runtime you will have to install the runtime dependencies (and in the uncommented areas there’s none of them added, you just copy over the compiled files, but I wonder if they are linked to any libraries for example that are not installed in that step.

It seems like my final image doesn’t have all dependencies. My image has some pretty complicated dependencies. But I’m testing including different files, so I hope to have a smaller image soon. Thanks again!