This is a creation in Article, where the information may have evolved or changed.
Use Docker to create a new Images on Ubuntu 14.04
Environment preparation
After Ubuntu 14.04.1 LTS was released, I happily went to the official website to download and create a virtual machine, but in executing the following command:
sudo apt-get update
Will always encounter the following error
W: 无法下载 http://extras.ubuntu.com/ubuntu/dists/trusty/main/binary-amd64/Packages Hash 校验和不符W: 无法下载 http://extras.ubuntu.com/ubuntu/dists/trusty/main/binary-i386/Packages Hash 校验和不符
Google to find a solution, tried again, the problem remains. The most puzzling is that Ubuntu official source inside this address is there, the content is also exist, in the browser can also be accessed but is unable to Update. Finally, the following attempts are made:
- Add the following to/etc/resolv.conf, using Google's DNS resolution:
nameserver 8.8.8.8nameserver 8.8.4.4
- Execute the following command in turn:
sudo rm -rf /var/lib/apt/lists/*sudo mkdir /var/lib/apt/lists/partialsudo apt-get cleansudo apt-get update
Unfortunately, the problem still exists, and because of the use of official sources, the speed is slow. Change the domestic source bar, fortunately Ubuntu Update Manager can detect the current network environment in the fastest third-party source, after detection, to my network, the fastest yun-idc.com Mirror. Clean up the cache again and re-update, then ...
Do the same thing over and over again, but expect a different result ———— Einstein
The result is still the same, just as the update speed is a bit faster. Although it has not affected the normal installation of software and daily work, but think of the above Warning is still very depressed. More crucially, when using Dockerfile to Build a new image, because the Base image is an official Clean system, you need to apt-get the update step, the above error will cause this command to return 100 instead of 0,dock The ER's Build process will also be interrupted, really depressed.
Since there is no effective solution, think of workaround. Since Extras.ubuntu the address of the package may not be used, it will not update this address, and then if necessary, can be resolved by adding PPA. So from/etc/apt/sources.list inside remove Extras.ubuntu address related content, again update finally no error.
Creating Nginx and Python images
Based on the solution mentioned above, I created two dockerfiles to create my own Nginx and Python development environment images:
# Pull base image.FROM dockerfile/ubuntu# Patch the proper apt-get sourcesADD assert/sources.list /etc/apt/sources.list# Install Nginx.RUN \ add-apt-repository -y ppa:nginx/stable && \ apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 16126D3A3E5C1192 && \ apt-get update && \ apt-get install -y nginx && \ rm -rf /var/lib/apt/lists/* && \ chown -R www-data:www-data /var/lib/nginx# Define mountable directories.VOLUME ["/etc/nginx/sites-enabled", "/etc/nginx/conf.d", "/var/log/nginx"]# Expose ports.EXPOSE 80
# Pull base image.FROM dockerfile/ubuntu# Patch the proper apt-get sourcesADD assert/sources.list /etc/apt/sources.list# Install Python Dev Env.RUN \ apt-get update && \ apt-get install -y python python-dev python-virtualenv# Expose ports.EXPOSE 8080
These two repositories are associated with my official Docker image library:
- Ubuntu-nginx
- Ubuntu-python
have been successfully build in the Docker registry Hub. The choice of Dockerfile/ubuntu is due to its official availability and the pre-installation of commonly used tools such as Git,curl.
Note : The main purpose of this article is to create your own Docker image, and the Container created with Ubuntu-nginx image cannot be run in daemon mode. Nginx in the production environment needs to be run in the Docker container using the- d option so that Nginx itself cannot run in the daemon state and can be deployed with reference to this scenario on Github.
--EOF--
- Implement RESTful api→ based on Flask
- ←ubuntu 14.04 system based on Gunicorn and Nginx deployment Flask applications
Disclaimer: This article uses the BY-NC-SA protocol to authorize. Reprint please specify transfer from: Ubuntu 14.04 using Docker to create a new Images