Docker Run Tar File

2/13/2022by admin

This is the recommended workflow for creating your own Docker image for your application:

Docker import URL/FILE Create an image from a container: docker commit CONTAINER NEWIMAGENAME Remove an image: docker rmi IMAGE Load an image from a tar archive or stdin: docker load TARFILE/STDINFILE Save an image to a tar archive, streamed to STDOUT with all parent layers, tags, and versions: docker save IMAGE TARFILE. $ docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE $ docker load tar.gz Loaded image: busybox:latest $ docker images REPOSITORY TAG IMAGE ID CREATED SIZE busybox latest 769b9341d937 7 weeks ago 2.489 MB $ docker load -input fedora.tar Loaded image: fedora:rawhide Loaded image: fedora:20 $ docker images REPOSITORY TAG IMAGE ID.

  • Write a Dockerfile for your application.
  • Build the image with docker build command.
  • Host your Docker image on a registry.
  • Pull and run the image on the target machine.

Write the Dockerfile

Docker builds images automatically by reading the instructions from a Dockerfile. It is a text file that contains all commands needed to build a given image. In this example, we will build and run the Hello ZED tutorial application in a container.

First let’s prepare the host with the code:

We provide some extra arguments to CMake to ensure that CMake and GCC can find all the required CUDA libraries. We also tell the compiler to allow linking even if there are undefined symbols from libraries such as nvcuvid that are not yet available. These will be available at runtime using NVIDIA container toolkit.

For more information on writing dockerfiles, check Dockerfile reference documentation.

Build your Docker Image

Now that you have created a Dockerfile, it’s time to build your image using the docker build command.

Tips: On NVIDIA Jetson, we recommend building your Jetson Docker Container on x86 host, and running it on the target Jetson to avoid long compilation time on boards such as Jetson Nano.

Test your Image

Let’s start the container based on the new image we created using the docker run command.

On Jetson or older Docker versions, use these arguments:

You should now see the output of the terminal.

Optimize your Image Size

Docker images can get very large and become a problem when pulling over the network or pushing on devices with limited storage (such as Jetson Nano). Here are a few advice to keep your image size small:

  • Minimize the number of RUN commands. Each command adds a layer to the image, so consolidating the number of RUN can reduce the number of layers in the final image. Note that layers are designed to be reusable, and will not be pushed or pulled if they didn’t change.

  • Use --no-install-recommends when installing packages with apt-get install to disable installation of optional packages and save disk space.

  • Remove tarballs or other archive files that were copied during the installation. Each layer is added on top of the others, so files that were not removed in a given RUN step will be present in the final image even they are removed in a later RUN step.

  • Similarly, clean package lists that are downloaded with apt-get update by removing /var/lib/apt/lists/* in the same RUN step.

  • Create separate images for development and production. Production images should not include all of the libraries and dependencies pulled in by the build.

  • Use multi-stage builds (see Docker docs) and push only your prod image.

Host your Docker Image

Now that you have created your image, you need to share it on a registry so it can be downloaded and run on any destination machine. A registry is a stateless, server-side application that stores and lets you distribute Docker images.

Use Docker Hub Registry

By default, Docker provides an official free-to-use registry, DockerHub, where you can push and pull your images.For example at Stereolabs, the ZED SDK Docker images are built automatically by a public Gitlab CI job and pushed to Stereolabs DockerHub repository.

There are situations where you will not want your image to be publicly available. In this case, you need to create your own private Docker Registry. You can get private repos from Docker, or from many other third-party providers.

Use Local Registry Server

For local development, if your host and target machines are on the same network, you can setup a local registry server and push your images there.


For more information on deploying your own registry server, please refer to Docker docs.

Save and Load Images as Files

Lastly it is also possible to export and load your Docker image as a file.

To export a Docker image simply use :

Tar file extractor

On the destination machine, simply load the Docker image using :

Next Steps

At this point, you have successfully created a Docker image for the “Hello ZED” application and learnt how to host and share it.

Let’s learn now how to Run and Build Jetson Docker Containers on x86 to speed up development and deployment on embedded boards such as Jetson Nano, without needing cross compilation.

Copyright © 2021 Stereolabs Inc.

To install packages in a docker container, the packages should be defined in the Dockerfile. If you want to install packages in the Container, use the RUN statement followed by exact download command. $ RUN pip install //IN Windows $ RUN apt-get install //in Ubuntu $ RUN yum install //CentOS/RHEL. Mac & Windows: install the Docker Toolbox to get Docker installed. As the generated files are in your shared folder, they will not be deleted if you stop your Docker container. However, if you don’t want Docker to keep downloading all the Maven and NPM dependencies every time you start the container, you should commit its state or mount a volume.

Docker Java Example

We shall learn following items in this Docker Java Example :

Build Docker Image with Java Application

1. Create a directory

A separate directory is useful to organise docker applications. For this Java Example, create a directory somewhere with name of your choice. We shall use the name java-application

2. Create Java Application


Create a simple Java File, in the directory java-application, with name containing the following content.

Docker Run Tar File Download

3. Dockerfile

Create a file with name Dockerfile. Dockerfile contains instructions to prepare Docker image with our Java Application.

Following is the content of Dockerfile.

4. Verify contents of java-application directory

Docker Run Tar File In Linux

5. Build docker image

Docker Run Tar File

Login as root user. Navigate into java-application directory and run the following command. Instructions in the Dockerfile are executed.

Please observe that there is dot (.) at the end of the command. Docker image is successfully built.

6. Check the docker image

To display available docker images, run the following command.

Run Docker Java Example

Run the following command to run the java-application Docker image in a container.

The Java Application has run, and the print statement could be seen in the console.

Docker Run Tar File

Save Docker Image to a tar file

Save the Docker Image file to a tar file, so that the image file could be copied to other machines through disk storage devices like pen-drive, etc.

Docker Run Tar File Opener

Install Kafka And Zookeeper In Dockerfile

Run the following command to save Docker image as a tar file.

Saving might take few seconds. Wait for the command to complete.

Copy and Run the Docker Image file in another machine

Install Kafka On Docker Windows 10

You may copy the Docker image tar file to another computer.

Run the following command to load the Docker image into the Docker.

Replace /home/arjun/workspace/java-application.tar with your file location.

You may run the image using the same command we used to run the image file after building.

Create Tar File

Install Kafka In Docker Download

Docker Run Tar File Download


Install Kafka In Docker Container

In this Docker Tutorial – Docker Java Example, we have learnt to build a Docker Image with Java Application and also how to save the image to a file and transfer it to other computers or servers.

Comments are closed.