Docker does not build image - docker

I just got started with docker and was following fireship's tutorial, however I encountered a problem when I ran the docker build command. I was expecting a similar output as the video (timestamp). Instead, I got the following:
Dockerfile
FROM node:12
WORKDIR /app #maybe its this? There is no /app directory
COPY package*.json ./
RUN npm install
COPY . .
ENV PORT=8080
EXPOSE 8080
CMD ["npm","start"]
docker build command
docker build -t <my docker id>/firstapp:1.1 .
File tree
D:/
Code/
testing/
Docker/
test1/
Notes
Yes, I have a docker ID.
The docker build command stopped at COPY . ., rather than finishing at CMD ["npm","start"]
CWD (Windows): D:\Code\testing\Docker\test1
I ran the docker build command twice
Questions
Why is this happening?
How can it be fixed?

The reason this occurs is because fireship is running Linux (like Hans Kilian noted) and I am running Windows. To get your image ID, run the docker images command, which will list your images w/ their image ID.
However, I am still not sure why it does not complete all 8 steps.

Related

Cannot find module DOCKER RUN

I am trying to run a simple docker image with a index.js file in my /build folder with a simple console.log('Hello world')
My docker file is:
FROM node:alpine
WORKDIR /test/build
COPY ./ ./
CMD node index.js
I create the image in my directory with:
docker build -t hello-docker .
Then I run:
docker run hello-docker
But I keep on getting the error:
cannot find module /test/build/index.js
How can I solve this?
Capturing my comment as an answer for posterity - since the docker build command will be run from the application's root, the index file will end up under the build directory. I.e., the application should be run using:
CMD node ./build/index.js

Docker - Getting manifest for openjdk:8-java-alpine not found

I tried small docker application.
This is my Dockerfile:
FROM openjdk:8-java-alpine
ADD target/hello-world-rest-api.jar hello-world-rest-api.jar
ENTRYPOINT ["java","-c","java -jar /hello-world-rest-api.jar
Getting the below error when I tried to run build cmd.
C:\Docker-SpringBoot-Projects\docker-crash-course-master\01-hello-world-rest-api>docker build -t dowlathbasha/hello-world-rest-api:dockerfile1 .
Sending build context to Docker daemon 16.97MB
Step 1/3 : FROM openjdk:8-java-alpine
manifest for openjdk:8-java-alpine not found
Pls, suggest.
There is no image named, openjdk:8-alpine hosted in Docker Hub
Try using alternative image such as FROM openjdk:8-alpine in Dockerfile
you may use following docker image for java8
FROM adoptopenjdk/openjdk8:x86_64-alpine-jre8u232-b09
RUN mkdir /app
COPY ./target/hello-world-rest-api.jar /app/hello-world-rest-api.jar
WORKDIR /app
CMD ["java", "-jar", "hello-world-rest-api.jar"]
source:- https://hub.docker.com/r/adoptopenjdk/openjdk8

Running .net core docker image, says application started, but on browsing gives "This site can’t be reached" error

I am having Windows 10 Home operating system. I have installed Docker toolbox.
My docker file is as follows:
FROM microsoft/dotnet:1.1-sdk-projectjson
COPY . /app
WORKDIR /app
RUN ["dotnet", "restore"]
RUN ["dotnet", "build"]
EXPOSE 5000/tcp
ENV ASPNETCORE_URLS http://*:5000
ENTRYPOINT ["dotnet", "run"]
I have created docker image by using following command:
$ docker build -t test:webApp3 .
I tried running the image by using following commands:
$ docker run -d -p 8080:5000 -t test:webApp3
$ docker run test:webApp3
Command says application started, but on browsing gives "This site can’t be reached" error.
Can someone please tell me, why its giving me specified error?
Plus can someone tell me, where does docker save created images on Windows 10 OS?
I was able to fix this by referring to following link:
https://medium.com/trafi-tech-beat/running-net-core-on-docker-c438889eb5a#.s3krizvtw
I was required to add, .UseUrls("http://*:5000/") in Main() of Program.cs.
Then I was able to browse, by using following URL:
http://192.168.99.100:5000/api/values

Where does the output for "docker -build" go?

I'm trying to build a sample docker image. When I run the following command:
docker build -t sample .
Where does the docker image go?
Here is my Dockerfile:
FROM node:boron
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Install app dependencies
COPY package.json /usr/src/app/
RUN npm install
# Bundle app source
COPY . /usr/src/app
EXPOSE 8080
CMD [ "npm", "start" ]
Use:
docker images
to see it
Example:
REPOSITORY TAG IMAGE ID CREATED SIZE
sample latest c660b762fcd1 5 days ago 1.46GB
They get stored as a series of layers in your Docker root directory. On Linux, it's /var/lib/docker.
after building you docker image run
docker image ls
then pick the image name you are interested (from first column) and run
docker image inspect <image name>
you will see there is about that image including location

Docker ONBUILD COPY doesn't seem to copy files

I am trying to copy files to a docker image when I execute the docker build command. I am not sure what I am doing wrong because this seems to work for the docker rails onbuild file but doesn't work for my custom dockerfile.
Here is my Dockerfile
FROM ubuntu:14.04
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
ONBUILD COPY Gemfile /usr/src/app
CMD ["tail", "-f", "/dev/null"]
The docker commands that I run are the following.
docker build -t copy-test .
docker run --name run-test -d copy-test
docker exec -i -t 2e9adebae0fc /bin/bash
When I connect to the container with docker exec it starts in /usr/src/app but the Gemfile is not there. I don't understand why the mkdir and WORKDIR instructions seem to work but the ONBUILD COPY does not. (And yes the directory I am invoking these commands in does have a Gemfile present)
You have to use COPY to build your image. Use ONBUILD if your image is kind of template to build other images.
See Docker documentation:
The ONBUILD instruction adds to the image a trigger instruction to be executed at a later time, when the image is used as the base for another build. The trigger will be executed in the context of the downstream build, as if it had been inserted immediately after the FROM instruction in the downstream Dockerfile.

Resources