windows docker unknown instruction VERSION: - windows

I'm trying to run a "docker build" command for a specified file but I always get an "unknown instruction" message no matter what instruction is inside yml file (the only one which worked for me was FROM instruction).
The yam file starts with the following
version: '3'
services:
After running I get the following:
Error response from daemon: Dockerfile parse error line 1: unknown instruction: VERSION:
Operating System is: Windows 7
docker version 18.01.0
Tried to save the file with different encodings, no one worked for me.
Does anyone know a solution?

VERSION is not a valid line in a Dockerfile. You appear to be confusing a Dockerfile with a docker-compose.yml. These are two different files, with two different syntaxes and purposes.

If your using a yml file try docker-compose rather than docker build. Otherwise try prefixing the version information with LABEL e.g.
LABEL version="1.0"

Related

docker inside container no longer works

previously, prior to a docker update, i think, i would build an docker image and then tunnel in locally with the below command. it has always worked. but now, it doesn't.
this code worked (to tunnel into a local directory on my computer so the docker can access it)
docker run -it -v [directory]:/inside-container [image id]  bash
now, it throws this error:
docker: invalid reference format.
See 'docker run --help'.
i cannot understand what changed.
any suggestions?
A "reference" is a pointer to an image.
"Invalid reference format" error frequently happens when an invalid arg gets parsed as the image name or invalid characters from copy/pasting from a source that changes dashes and quotes.
https://sudo-bmitch.github.io/presentations/dc2018/faq-stackoverflow-lightning.html#29
Doesn't your dir contain spaces?
Double-check the syntax, like quotes, hidden symbols etc.
there were issues with the versioning of docker, and when i got the latest updated, everything worked again. very strange that exactly the same code-line didn't run on a prior version. i'm not sure how i feel about all that, but it's corrected now on version: Docker version 19.03.13

Running docker run command on windows

I am a beginner in docker and I am trying to run a Q&A website locally in my browser. I have found an open source container on the link https://hub.docker.com/r/zout84/askbot-docker. Here are the steps that I have done:
I have downloaded docker toolbox DockerToolbox-19.03.1.exe to be able to run docker using my Windows terminal.
Following the instructions on the above link I have run the command docker run -v /tmp/askbot:/data/ -p 8080:80 -d zout84/askbot-docker. Since I am on Windows I have replaced /tmp/askbot:/data/ by a folder I have created.
I have downloaded the container and put it a local folder that I called Docker_source. I have replaced zout84/askbot-docker by C:\Docker_source in the above docker run command
Now the error that I have is docker: invalid reference format: repository name must be lowercase.
Please, any suggestions on how to make it work?
Like the error said, The repository has to be lower case. It is called C:\Docker_source. You got a capital "D" over there. change it to a "d"

How to Access Files on my computer through Docker

I am running Docker on my Windows 10 Home computer. I am trying to run the following code
$ docker run -i -t -v /Users/Maddy/Desktop/Docker:/home bcain/lensing /bin/bash
which gives me the following
DOCKER-lensing >
which then I can input the program I need to run (lenstool) that uses a file on my computer (MACS0417.par) which lives on my computer in /Users/Maddy/Desktop/Docker
Docker-lensing > lenstool MACS0417.par -n
which then gives me
You are running openMP version of lenstool with 1 threads
You can change the number of threads by set environment variable OMP_NUM_THREADS
ERROR: file MACS0417.par not found
The path to the files I want to access from my computer was specified with
-v /Users/Maddy/Desktop/Docker
I have researched other similar questions that aloud me to check to see if my local drive was successfully located under docker volume and It is.
to check this I did the following:
docker volume ls
which reads
DRIVER VOLUME NAME
local UsersMaddyDesktopDocker
Am I missing something? I am a beginning coder and begining Docker user. Thank you for your time and I probably left some vital information out so please ask what other information you need. Thank you in advance,
-Maddy
UPDATE May 22nd 2018-
I have looked up and followed the directions for docker compose. I am now trying to edit the volumes but am not quite sure how I would go about doing this. The code I have in my yml file so far is this
version: '3'
services:
web:
build: .
ports:
- "5000:5000"
volumes:
- .:/code
redis:
image: "redis:alpine"
I understand that I need to add something under volumes but I am not sure what I should put? (I am currently looking more into this but if anyone can guide me more I would be very appreciative!)
If you want to mount anything then you will have to map it from your local to the desired location on the container.For that you need to create a docker compose file , inside that yaml there is place holder called volumes there you need to specify the location of local file : to the place in the container. You can search for docker compose documentation and you will get an idea.

docker-compose up with volumes "no such file or directory"

I'm a beginner in working with docker especially docker compose. Currently, creation my initial easy docker environment, I run into the first error and I've no clue why.
I tried to search for a solution in stackoverflow but found nothing that could help me.
Starting my docker with "docker-compose up" I get the following error:
$ docker-compose up
Removing errorinstance_app_1
Recreating 8a358dfcb306_8a358dfcb306_8a358dfcb306_errorinstance_app_1 ...
Recreating 8a358dfcb306_8a358dfcb306_8a358dfcb306_errorinstance_app_1 ... error
ERROR: for 8a358dfcb306_8a358dfcb306_8a358dfcb306_errorinstance_app_1 Cannot start service app: oci runtime error: container_linux.go:265: starting container process caused "exec: \"./run.sh\": stat ./run.sh: no such file or directory"
ERROR: for app Cannot start service app: oci runtime error: container_linux.go:265: starting container process caused "exec: \"./run.sh\": stat ./run.sh: no such file or directory"
ERROR: Encountered errors while bringing up the project.
So. Following my folder structure:
Project
docker-compose.yml
Docker
Java
Dockerfile
src
run.sh
Following my docker-compose.yml:
version: '2'
services:
app:
build:
dockerfile: ./Docker/Java/Dockerfile
context: .
volumes:
- ./src:/usr/local/etc/
working_dir: /usr/local/etc/
command: ./run.sh
And following my docker file:
FROM java:7-jdk-alpine
# WORKDIR /usr/local/etc
run.sh
echo "Hello world."
Yes, I know that I could do that solution only in a docker-compose file. But in the future I need to extend the Dockerfile.
Can someone help me respectively does anyone see the issue?
The problem is with the base docker image you are using in dockerfile:
FROM java:7-jdk-alpine
You are trying to start container by running run.sh bash script. But the above image doesn't support bash itself
For reference, you can see the documentation of above image in docker hub page here. Quoting the necessary portion here:
java:alpine
...
To minimize image size, it's uncommon for additional related tools
(such as git or bash) to be included in Alpine-based images. Using
this image as a base, add the things you need in your own Dockerfile
(see the alpine image description for examples of how to install
packages if you are unfamiliar).
That's about the problem.
Now, I can think of 2 solutions:
Just use java:7-jdk as base image instead of java:7-jdk-alpine
Install bash on top of the base image java:7-jdk-alpine by changing dockerfile to:
FROM java:7-jdk-alpine
RUN apk update && apk upgrade && apk add bash
#WORKDIR /usr/local/etc
*source of steps to install bash in alpine linux is here
It looks like docker compose can't find your run.sh file. This file needs to be included in your docker image.
Change your Dockerfile to the following, then rebuild the image with docker build -t <YOUR_IMAGE_NAME> ..
FROM java:7-jdk-alpine
ADD run.sh /usr/local/etc/run.sh
Once your image is rebuilt, run docker-compose up again.
The easiest way to tackle the problem is to execute a bash session in the container, then inside the container, you have to check if the file exists in the
indicated path if the file is not in the path, it must be included when you create the image into the docker file or through a volume inside de docker-compose.
Another thing to check is the relative path you are using. It will be clear when you check the existence of the file inside de docker container
docker exec -it CONTAINER_NAME bash
I recommend you to create a volume in the docker compose file, as it is the easier way, and also the best way.
there is a question that I want to do you, why are you putting the Dockerfile file inside a Java path?
It is not a good idea o guideline to follow
The correct way is to put your dockerfile file into an environment folder, in such a way the dockerfile file is not related to the java source of your application
I got this Error quite a lot and after a lot of investigation, it looked like some images were corrupted.
Deleting those and rebuilding solve the problem. It was not docker installation or configuration itself.

error while starting Titan database using docker

I want to start using titan database and I have followed http://oren.github.io/blog/titan.html instructions. But when I try to start titan in docker it gives me the following error:
/opt/titan-0.5.4-hadoop2/run.sh: 2: /opt/titan-0.5.4-hadoop2/run.sh: : not found
run.sh file located in C:\Users\Modeso\titan but I can't find a way to change the folder location in docker.
Has anyone faced this problem before or have solution for it?
I suspect that in this case, the "not found" message may not be because the file is not found, but because the wrong line-endings are used in the file. If a shell-script uses Windows line-endings, Linux can produce weird errors, such as this one.
Did you try building from the GitHub repository? https://github.com/apobbati/titan-rexster
You can build an image from that repository through;
docker build -t titan-rexter github.com/apobbati/titan-rexster
And run it;

Resources