Search code examples
visual-studiodockervisual-studio-codedockerfiledocker-machine

How to create custom image in docker using VSCode?


I am new to docker, and I'm creating new custom alpine docker image using VSCode. Below is the set of commands I have mentioned on my file(Dockerfile):

# Step1 specify the base image
FROM alpine

# Download and install dependencies
RUN apk add --update redis

# Setup the startup command
CMD ["redis-server"]

Now, when I am running the docker build command in vs terminal, I am getting an error,

PS C:\Users\ankurpandey\Desktop\StudyMaterial\dockerfile-custom> docker build .

[+] Building 0.1s (2/2) FINISHED

 => [internal] load .dockerignore 0.1s
 => transferring context: 2B 0.0s  
 => [internal] load build definition from Dockerfile 0.0s  
 => transferring dockerfile: 2B 0.0s 

failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount460459348/Dockerfile: no such file or directory    

I have created only one plain file in my root folder dockerfile-custom i.e., Dockerfile as shown in the image

Please suggest me what going wrong with the steps? Thanks!!


Solution

  • I see that you are trying to build a redis-server, the image of redis is already available on docker hub - have you tried that out?

    https://hub.docker.com/_/redis

    Check this link - the same issue is discussed and resolved.

    It seems on windows - if you try

    docker build -f <name of your dockerfile> .

    it should work fine.