Dockerize Apache Tomcat on Windows

This stackoverflow post [1] explains how it is possible to build and run an image for Java Web Application on Tomcat, via Docker, but if you are working on Windows, probably it is not going to work for you, because you may face with

cannot enable tty mode on non tty input. [2]

Let’s try something to get over this.

* Create a folder in Desktop as “docky”.
* Copy your war file to “docky”.
* Create a file without file extension called “Dockerfile”.

FROM tomcat

ADD yourApp.war /usr/local/tomcat/webapps/

CMD ["", "run"]

Do NOT change “/usr/local/tomcat/webapps/” part. Just replace “yourApp.war” with name of your actual war file.

Open C:\Program Files\Docker Toolbox.
Run to start Docker.
After MINGW64 is opened go to “docky” in command line.

Type command:

docker build -t yourName .

Don’t forget “.” at the end. “.” shows path of Dockerfile.

If you type

docker run --rm -it -p 8080:8080 yourName

to start Tomcat, exception is shown which is mentioned above.


Now open Oracle VM VirtualBox.
Double click default VM to open.
Please read instructions on popup before click Next/OK/Capture etc.

After VM is ready you can type

docker run --rm -it -p 8080:8080 yourName

to start Tomcat.

To exit from VM, press “Right Ctrl” on keyboard.

So Tomcat is running in VM, but how can we access it?

Right click to default VM > Settings > Network > NAT in Oracle VM VirtualBox screen.
Click “Port Forwarding”.
Add new record as

TCP 8080 8080


So 8080 port of your VM is linked to your PC’s 8080 port.

Now open your browser and go to http://localhost:8080/ and you should see default Tomcat page.
Lastly try http://localhost:8080/yourApp and I hope it works!







Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: