Win at 2048 with Docker and ShutIt (Redux)

This post is based on material from Docker in Practice, available on Manning’s Early Access Program. Get 39% off with the code: 39miell

dip

Steps to win at 2048

I blogged about this before, but have revisited it and made the process much easier and more robust.

1) To play 2048:

docker run -d -p 5901:5901 -p 6080:6080 --name win2048 imiell/win2048

2) Start up the vnc session:

vncviewer localhost:1

password for vnc is:

vncpass

Play for a bit.

3) When ready to “save game”:

docker tag -f my2048tag $(docker commit win2048)

Then, if you lose

4) go back to your save point with:

docker rm -f win2048
docker run -d -p 5901:5901 -p 6080:6080 --name win2048 my2048tag

and repeat steps 2) to 4) until you complete 2048!

Notes:

Command Annotations

docker run -d -p 5901:5901 -p 6080:6080 --name win2048 imiell/win2048

-d – run the container in daemon mode

-p … – publish ports related to vnc to the host

–name – give the container a name we can easily reference later

vncviewer localhost:1

Access the vncviewer on the ports  5901 and 6080.

docker tag -f my2048tag $(docker commit win2048)

The subshell (in italics) commits the files in the container to a docker image. The command returns a reference to the image that is in turn passed to the docker tag command. This forces the tag for the image to be set to my2048tag (or whatever you choose to call it.

docker rm -f win2048
docker run -d -P --name win2048 my2048tag

We must remove the container running so that the names don’t clash when we start it up again with docker run.

Build it Yourself

If you want to build the image yourself:

docker build https://raw.githubusercontent.com/ianmiell/shutit/master/library/win2048/Dockerfile

will make a local image you can tag. Code is here

Advertisements

One thought on “Win at 2048 with Docker and ShutIt (Redux)”

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s