I in the process of dockerizing an angular 9 application. My plan is to build the Docker from "scratch" then add the Ubuntu Bionic followed by Nginx followed by Angular and finally the theme assets and application UI code.

I have docker on a VPS (I know its strange but then didn't have a baremetal on the cloud to install it) while the docker CLI is on my laptop. I have set the DOCKER_HOST varable as follows

export DOCKER_HOST=ssh://sridhar@999.99.999.999:9999

This allows me to connect to the Docker engine on the VPS using my laptop (running Ubuntu). I am able to list the images, deploy containers et all.

I have the following docker file

# Specifying the base image. We would like to create from scratch and then add the layers
FROM scratch

# We will now add the layers as follows Ubuntu 18.04, Nginx, 
ADD docker pull ubuntu:focal-20201008 /

When I try to build the image I get the following error

$ docker build --tag abui .
Sending build context to Docker daemon  104.2MB
Step 1/2 : FROM scratch
Step 2/2 : ADD docker pull ubuntu:focal-20201008 /
ADD failed: stat /var/lib/docker/tmp/docker-builder302666646/docker: no such file or directory

I am unable to understand why the Ubuntu Image cannot be added.

  • 1
    what will happen if you use RUN instead of ADD. ADD is similar to COPY, as far as I know, according to the error message it is trying to add the docker file, (which is not there) from the current location to somewhere. – Prakash Nov 2 '20 at 11:29
  • ADD tries to add files to your image, while docker pull is a shell command that will import a new image to docker. This is mixing several concepts, and I'd be surprised if it'd work this way. But first, why don't you simply start from the ubuntu image with FROM ubuntu:focal-20201008? – Lykanion Nov 2 '20 at 12:58
  • @Lykanion please post your comments as answer. Will accept it. Took me sometime to realize it. I have started FROM the Ubuntu image because I feel that as application developers it's better to start from the OS and the OS image anyway would be FROM scratch. – sridhar pandurangiah Nov 2 '20 at 14:24
  • 1
    glad to help :) – Lykanion Nov 3 '20 at 8:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.