5

I'm trying to create a VM with docker and boot2docker. I've made the following Dockerfile, which I'm trying to run through the command line

docker run Dockerfile

Immidiatly it says exactly this:

Unable to find image 'Dockerfile:latest' locally
FATA[0000] Invalid repository name <Dockerfile>, only [a-z0-9_.] are allowed

Dockerfile:

FROM ubuntu:latest

#Oracle Java7 install
RUN apt-get install software-properties-common -y
RUN apt-get update
RUN add-apt-repository -y ppa:webupd8team/java
RUN apt-get update
RUN echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select                        true | /usr/bin/debconf-set-selections
RUN apt-get install -y oracle-java7-installer

#Jenkins install
RUN wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo      apt-key add -
RUN sudo echo "deb http://pkg.jenkins-ci.org/debian binary/" >>  /etc/apt/sources.list
RUN apt-get update
RUN apt-get install --force-yes -y jenkins
RUN sudo service jenkins start

#Zip support install
RUN apt-get update
RUN apt-get -y install zip

#Unzip hang.zip
RUN unzip -o /var/jenkins/hang.zip -d /var/lib/jenkins/
RUN chown -R jenkins:jenkins /vaR/lib/jenkins
RUN service jenkins restart
EXEC tail -f /etc/passwd


EXPOSE 8080

I am in the directory where the Dockerfile is, when trying to run this command.

Ignore the zip part, as that's for later use

Detilium
  • 2,868
  • 9
  • 30
  • 65

2 Answers2

5

You should run docker build first (which actually uses your Dockerfile):

docker build --tag=imagename .

Or

docker build --tag=imagename -f yourDockerfile .

Then you would use that image tag to docker run it:

docker run imagename
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • It's working with `docker build .`, it's now building the image. Ofc I can't run `docker run` since the image doesn't exist yet. Thank you – Detilium May 04 '15 at 07:23
1

There are tools that can provide this type of feature. We have achieved using docker compose, though you have to go through

(https://docs.docker.com/compose/overview/) 

docker-compose up

but you can also do as work around

$ docker build -t foo . && docker run foo.
Anuj Singh
  • 11
  • 4