Search code examples
boot2dockerdockerfile

Dockerfile creation and building image


I am new to docker. I have installed docker using Boot2docker on my windows. But I do not have clear idea how to deploy simple java web app in docker.

I have gone through the net and came to know that from docker file create build an image and run it.

I created one dockerfile and placed in D:\dock folder. I ran docker build command like this i.e
$ docker build -t tomcat7-test Dockerfile's path.

But it did not recognize my file.

Where should be my Dockerfile should exist if I create through notepad++ and how docker recognize my docker file with docker build command?


Solution

  • Your Dockerfile should be copied into boot2docker VM in order to run it. You can do one of the following:

    1. create Dockerfile in boot2docker manually (note: filesystem is read-only, you should do 'sudo -s' before running docker build, or
    2. mount a folder from your local filesystem
    3. use

    How to add shared folder into boot2docker VM:

    VBoxManage.exe sharedfolder add boot2docker-vm --name /c/Users --hostpath C:/Users --automount
    

    By using option 2 you can edit Dockerfile from your home directory and run docker on the same Dockerfile (replace the example with a real path to Dockerfile):

    docker build -t myimage /c/Users/xyz