adamkdean

software engineering

Local DNS resolver found in resolv.conf and containers can't use it

By Adam K Dean on

I've been playing with Docker for part of a project, and came across this annoying but important message:

WARNING: Local (127.0.0.1) DNS resolver found in resolv.conf and containers can't use it. Using default external servers : [8.8.8.8 8.8.4.4]

The problem? /etc/resolv.conf has nameserver 127.0.0.1 (or nameserver 127.0.1.1) in it.

I worked out that Ubuntu 14.04 LTS uses a daemon called dnsmasq, which routes DNS traffic through to the DNS servers provided by DHCP.

While this works fine for Docker, that message is quite annoying.

I disabled dnsmasq in /etc/NetworkManager/NetworkManager.conf:

$ sudo nano /etc/NetworkManager/NetworkManager.conf

#dns=dnsmasq

I then added the public Google DNS servers to /etc/dhcp/dhclient.conf:

$ sudo nano /etc/dhcp/dhclient.conf

prepend domain-name-servers 8.8.8.8,8.8.4.4;

Then you just need to restart NetworkManager:

$ sudo restart network-manager

And now you can start Docker containers without that pesky message!

Install Docker on Ubuntu

By Adam K Dean on

To install Docker on Ubuntu 14.04 LTS, run the following commands:

$ sudo apt-get install docker.io
$ sudo ln -sf /usr/bin/docker.io /usr/local/bin/docker

Once that is done, add your user to the docker group:

$ sudo usermod -a -G docker adam

After this, you may need to logout and login again. I had an issue where I recieved an error like this:

$ docker ps
dial unix /var/run/docker.sock permission denied

Once you've logged out and back in again, you can test docker is installed and works like so;

$ docker version
Client version: 0.9.1
Go version (client): go1.2.1
Git commit (client): 3600720
Server version: 0.9.1
Git commit (server): 3600720
Go version (server): go1.2.1
Last stable version: 0.11.1

Be sure to read up more at Getting Started

Install Sublime Text on Ubuntu

By Adam K Dean on

This relates to installing Sublime Text on Ubuntu 14.04 LTS.

For Sublime Text 2, run the following commands:

$ sudo add-apt-repository ppa:webupd8team/sublime-text-2
$ sudo apt-get update
$ sudo apt-get install sublime-text

For Sublime Text 3, run the following commands:

$ sudo add-apt-repository ppa:webupd8team/sublime-text-3
$ sudo apt-get update
$ sudo apt-get install sublime-text

Notice that it's just a case of changing sublime-text-2 to sublime-text-3.

Don't forget to Install Emmet (Zen Coding) and LESS highlighting too!

Flickr API Size enum

By Adam K Dean on

Just for future reference, here is the Flickr API sizes as a JavaScript enum.

var flickr_sizes = {
    'square':       '_s',
    'large_square': '_q',
    'thumbnail':    '_t',
    'small':        '_m',
    'small_320':    '_n',
    'medium':       '',
    'medium_640':   '_z',
    'medium_800':   '_c',
    'large':        '_b',
    'large_1600':   '_h',
    'large_2048':   '_k',
    'original':     '_o'
};

Import content using MonoGame & XNA

By Adam K Dean on

So I knew this was coming. I knew there would be issues with the content pipeline, long lost roots reaching back down into the abyss of XNA and unmaintained Microsoft projects. Game development is all about challenges. It's the reason I love it. Everything pushes you to the limit; mentally, physically, emotionally.

My first challenge is to get a MonoGame project up and running with the XNA pipeline. Luckily, the folks over at MonoGame have put a lot of effort into this already, and so it's quite straight forward. Then again, everything is once you've figured it out. Working against me is a fragmented web of outdated tutorials and insufficient documentation.

I am using Visual Studio 2012. I have Windows Phone SDK installed, which allowed me to install XNA Game Studio 4.0. I have also installed the Visual Studio 2012 XNA refresh extension, allowing me to do everything in VS2012. Finally, I have MonoGame installed.

I have created a project named Alpha, first of it's kind. In there I have added two new projects: a MonoGame Content Project, and a MonoGame Windows Project. The content project will create two projects. One will be called %name% and is an XNA content project, the other will be called %name%Content and is a MonoGame content project. I used the name Alpha, which gave me Alpha and AlphaContent. The MonoGame Windows Project will simply create a single project. I called it AlphaGame.

So now I have three projects: Alpha (XNA content), AlphaContent (MonoGame content), and AlphaGame (MonoGame windows).

The reason we need so much is because we rely on XNA to convert our content into XNA/MonoGame ready content. Once you're setup, you won't even need to worry about the particulars though. It's all very, very neat.

I've created two files; blue.png and green.png. I have a separate directory called assets which isn't part of the Visual Studio solution. I'll keep all my content here, and copy it when it's ready to the solution. To import them into the solution, I simply drag them into the Solution Explorer. We want them to belong to the AlphaContent project (the MonoGame content one).

Now when the project builds, they will be converted to XNA content. But we want to be able to access them in our AlphaGame.

Open up AlphaGame.csproj in a text editor. I use Sublime. At the bottom, we want to add in an AfterBuild script.

<Target Name="AfterBuild">
    <ItemGroup>
        <ContentSource Include="..\Alpha\Alpha\bin\PSM\Content\**\*.*" />
    </ItemGroup>
    <Copy SourceFiles="@(ContentSource)" DestinationFolder="$(TargetDir)\Content\%(RecursiveDir)" SkipUnchangedFiles="true" />
</Target>

You may need to change some paths to suit your project.

When we now rebuild our entire solution, we will get the following:

1>AfterBuild:
1>  Copying file from "..\Alpha\Alpha\bin\PSM\Content\Artwork\blue.xnb" to "C:\Users\Adam\Desktop\AlphaGame\src\AlphaGame\bin\Windows\Debug\\Content\Artwork\blue.xnb".
1>  Copying file from "..\Alpha\Alpha\bin\PSM\Content\Artwork\green.xnb" to "C:\Users\Adam\Desktop\AlphaGame\src\AlphaGame\bin\Windows\Debug\\Content\Artwork\green.xnb".

Now we can easily load the content like so:

protected override void LoadContent()
{
    this.Content.Load<Texture2D>("Artwork/blue");
}

This post may not be as easy to read as some of my others. Most of the time I ponder of what I'm writing, making sure to produce easy to read content. But my head is in game development, so I'm just doing a braindump. I'm going to start tagging these posts as braindumps.

P.S, make sure you set the game project to rely on the content project by right clicking the solution and going to build order, and setting the game project to depending on the content project.