Code Monkey home page Code Monkey logo

baseimage-docker's Introduction

A minimal Ubuntu base image modified for Docker-friendliness

Release

Baseimage-docker only consumes 8.3 MB RAM and is much more powerful than Busybox or Alpine. See why below.

Baseimage-docker is a special Docker image that is configured for correct use within Docker containers. It is Ubuntu, plus:

  • Modifications for Docker-friendliness.
  • Administration tools that are especially useful in the context of Docker.
  • Mechanisms for easily running multiple processes, without violating the Docker philosophy.

You can use it as a base for your own Docker images.

Baseimage-docker is available for pulling from the Docker registry and GHCR (GitHub Container Registry)!

What are the problems with the stock Ubuntu base image?

Ubuntu is not designed to be run inside Docker. Its init system, Upstart, assumes that it's running on either real hardware or virtualized hardware, but not inside a Docker container. But inside a container you don't want a full system; you want a minimal system. Configuring that minimal system for use within a container has many strange corner cases that are hard to get right if you are not intimately familiar with the Unix system model. This can cause a lot of strange problems.

Baseimage-docker gets everything right. The "Contents" section describes all the things that it modifies.

Why use baseimage-docker?

You can configure the stock ubuntu image yourself from your Dockerfile, so why bother using baseimage-docker?

  • Configuring the base system for Docker-friendliness is no easy task. As stated before, there are many corner cases. By the time that you've gotten all that right, you've reinvented baseimage-docker. Using baseimage-docker will save you from this effort.
  • It reduces the time needed to write a correct Dockerfile. You won't have to worry about the base system and you can focus on the stack and the app.
  • It reduces the time needed to run docker build, allowing you to iterate your Dockerfile more quickly.
  • It reduces download time during redeploys. Docker only needs to download the base image once: during the first deploy. On every subsequent deploys, only the changes you make on top of the base image are downloaded.

Related resources: Website | Github | Docker registry | Discussion forum | Twitter | Blog

Table of contents


What's inside the image?

Overview

Looking for a more complete base image, one that is ideal for Ruby, Python, Node.js and Meteor web apps? Take a look at passenger-docker.

Component Why is it included? / Remarks
Ubuntu 24.04 LTS The base system.
A correct init process Main article: Docker and the PID 1 zombie reaping problem.

According to the Unix process model, the init process -- PID 1 -- inherits all orphaned child processes and must reap them. Most Docker containers do not have an init process that does this correctly. As a result, their containers become filled with zombie processes over time.

Furthermore, docker stop sends SIGTERM to the init process, which stops all services. Unfortunately most init systems don't do this correctly within Docker since they're built for hardware shutdowns instead. This causes processes to be hard killed with SIGKILL, which doesn't give them a chance to correctly deinitialize things. This can cause file corruption.

Baseimage-docker comes with an init process /sbin/my_init that performs both of these tasks correctly.
Fixes APT incompatibilities with Docker See moby/moby#1024.
syslog-ng A syslog daemon is necessary so that many services - including the kernel itself - can correctly log to /var/log/syslog. If no syslog daemon is running, a lot of important messages are silently swallowed.

Only listens locally. All syslog messages are forwarded to "docker logs".

Why syslog-ng?
I've had bad experience with rsyslog. I regularly run into bugs with rsyslog, and once in a while it takes my log host down by entering a 100% CPU loop in which it can't do anything. Syslog-ng seems to be much more stable.
logrotate Rotates and compresses logs on a regular basis.
SSH server Allows you to easily login to your container to inspect or administer things.

SSH is disabled by default and is only one of the methods provided by baseimage-docker for this purpose. The other method is through docker exec. SSH is also provided as an alternative because docker exec comes with several caveats.

Password and challenge-response authentication are disabled by default. Only key authentication is allowed.
cron The cron daemon must be running for cron jobs to work.
runit Replaces Ubuntu's Upstart. Used for service supervision and management. Much easier to use than SysV init and supports restarting daemons when they crash. Much easier to use and more lightweight than Upstart.
setuser A tool for running a command as another user. Easier to use than su, has a smaller attack vector than sudo, and unlike chpst this tool sets $HOME correctly. Available as /sbin/setuser.
install_clean A tool for installing apt packages that automatically cleans up after itself. All arguments are passed to apt-get -y install --no-install-recommends and after installation the apt caches are cleared. To include recommended packages, add --install-recommends.

Baseimage-docker is very lightweight: it only consumes 8.3 MB of memory.

Wait, I thought Docker is about running a single process in a container?

The Docker developers advocate the philosophy of running a single logical service per container. A logical service can consist of multiple OS processes.

Baseimage-docker only advocates running multiple OS processes inside a single container. We believe this makes sense because at the very least it would solve the PID 1 problem and the "syslog blackhole" problem. By running multiple processes, we solve very real Unix OS-level problems, with minimal overhead and without turning the container into multiple logical services.

Splitting your logical service into multiple OS processes also makes sense from a security standpoint. By running processes as different users, you can limit the impact of vulnerabilities. Baseimage-docker provides tools to encourage running processes as different users, e.g. the setuser tool.

Do we advocate running multiple logical services in a single container? Not necessarily, but we do not prohibit it either. While the Docker developers are very opinionated and have very rigid philosophies about how containers should be built, Baseimage-docker is completely unopinionated. We believe in freedom: sometimes it makes sense to run multiple services in a single container, and sometimes it doesn't. It is up to you to decide what makes sense, not the Docker developers.

Does Baseimage-docker advocate "fat containers" or "treating containers as VMs"?

There are people who think that Baseimage-docker advocates treating containers as VMs because Baseimage-docker advocates the use of multiple processes. Therefore, they also think that Baseimage-docker does not follow the Docker philosophy. Neither of these impressions are true.

The Docker developers advocate running a single logical service inside a single container. But we are not disputing that. Baseimage-docker advocates running multiple OS processes inside a single container, and a single logical service can consist of multiple OS processes.

It follows that Baseimage-docker also does not deny the Docker philosophy. In fact, many of the modifications we introduce are explicitly in line with the Docker philosophy. For example, using environment variables to pass parameters to containers is very much the "Docker way", and providing a mechanism to easily work with environment variables in the presence of multiple processes that may run as different users.

Inspecting baseimage-docker

To look around in the image, run:

docker run --rm -t -i phusion/baseimage:<VERSION> /sbin/my_init -- bash -l

where <VERSION> is one of the baseimage-docker version numbers.

You don't have to download anything manually. The above command will automatically pull the baseimage-docker image from the Docker registry.

Using baseimage-docker as base image

Getting started

The image is called phusion/baseimage, and is available on the Docker registry.

# Use phusion/baseimage as base image. To make your builds reproducible, make
# sure you lock down to a specific version, not to `latest`!
# See https://github.com/phusion/baseimage-docker/blob/master/Changelog.md for
# a list of version numbers.
FROM phusion/baseimage:<VERSION>

# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]

# ...put your own build instructions here...

# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

Adding additional daemons

A daemon is a program which runs in the background of its system, such as a web server.

You can add additional daemons (for example, your own app) to the image by creating runit service directories. You only have to write a small shell script which runs your daemon; runsv will start your script, and - by default - restart it upon its exit, after waiting one second.

The shell script must be called run, must be executable, and is to be placed in the directory /etc/service/<NAME>. runsv will switch to the directory and invoke ./run after your container starts.

Be certain that you do not start your container using interactive mode (-it) with another command, as runit must be the first process to run. If you do this, your runit service directories won't be started. For instance, docker run -it <name> bash will bring you to bash in your container, but you'll lose all your daemons.

Here's an example showing you how a runit service directory can be made for a memcached server.

In memcached.sh, or whatever you choose to name your file (make sure this file is chmod +x):

#!/bin/sh
# `/sbin/setuser memcache` runs the given command as the user `memcache`.
# If you omit that part, the command will be run as root.
exec /sbin/setuser memcache /usr/bin/memcached >>/var/log/memcached.log 2>&1

In an accompanying Dockerfile:

RUN mkdir /etc/service/memcached
COPY memcached.sh /etc/service/memcached/run
RUN chmod +x /etc/service/memcached/run

A given shell script must run without daemonizing or forking itself; this is because runit will start and restart your script on its own. Usually, daemons provide a command line flag or a config file option for preventing such behavior - essentially, you just want your script to run in the foreground, not the background.

Running scripts during container startup

The baseimage-docker init system, /sbin/my_init, runs the following scripts during startup, in the following order:

  • All executable scripts in /etc/my_init.d, if this directory exists. The scripts are run in lexicographic order.
  • The script /etc/rc.local, if this file exists.

All scripts must exit correctly, e.g. with exit code 0. If any script exits with a non-zero exit code, the booting will fail.

Important note: If you are executing the container in interactive mode (i.e. when you run a container with -it), rather than daemon mode, you are sending stdout directly to the terminal (-i interactive -t terminal). If you are not calling /sbin/my_init in your run declaration, /sbin/my_init will not be executed, therefore your scripts will not be called during container startup.

The following example shows how you can add a startup script. This script simply logs the time of boot to the file /tmp/boottime.txt.

In logtime.sh:

#!/bin/sh
date > /tmp/boottime.txt

In Dockerfile:

RUN mkdir -p /etc/my_init.d
COPY logtime.sh /etc/my_init.d/logtime.sh
RUN chmod +x /etc/my_init.d/logtime.sh

Shutting down your process

/sbin/my_init handles termination of children processes at shutdown. When it receives a SIGTERM it will pass the signal onto the child processes for correct shutdown. If your process is started with a shell script, make sure you exec the actual process, otherwise the shell will receive the signal and not your process.

/sbin/my_init will terminate processes after a 5 second timeout. This can be adjusted by setting environment variables:

# Give children processes 5 minutes to timeout
ENV KILL_PROCESS_TIMEOUT=300
# Give all other processes (such as those which have been forked) 5 minutes to timeout
ENV KILL_ALL_PROCESSES_TIMEOUT=300

Note: Prior to 0.11.1, the default values for KILL_PROCESS_TIMEOUT and KILL_ALL_PROCESSES_TIMEOUT were 5 seconds. In version 0.11.1+ the default process timeout has been adjusted to 30 seconds to allow more time for containers to terminate gracefully. The default timeout of your container runtime may supersede this setting, for example Docker currently applies a 10s timeout by default before sending SIGKILL, upon docker stop or receiving SIGTERM.

Environment variables

If you use /sbin/my_init as the main container command, then any environment variables set with docker run --env or with the ENV command in the Dockerfile, will be picked up by my_init. These variables will also be passed to all child processes, including /etc/my_init.d startup scripts, Runit and Runit-managed services. There are however a few caveats you should be aware of:

  • Environment variables on Unix are inherited on a per-process basis. This means that it is generally not possible for a child process to change the environment variables of other processes.
  • Because of the aforementioned point, there is no good central place for defining environment variables for all applications and services. Debian has the /etc/environment file but it only works in some situations.
  • Some services change environment variables for child processes. Nginx is one such example: it removes all environment variables unless you explicitly instruct it to retain them through the env configuration option. If you host any applications on Nginx (e.g. using the passenger-docker image, or using Phusion Passenger in your own image) then they will not see the environment variables that were originally passed by Docker.
  • We ignore HOME, SHELL, USER and a bunch of other environment variables on purpose, because not ignoring them will break multi-user containers. See #86 -- A workaround for setting the HOME environment variable looks like this: RUN echo /root > /etc/container_environment/HOME. See #119

my_init provides a solution for all these caveats.

Centrally defining your own environment variables

During startup, before running any startup scripts, my_init imports environment variables from the directory /etc/container_environment. This directory contains files named after the environment variable names. The file contents contain the environment variable values. This directory is therefore a good place to centrally define your own environment variables, which will be inherited by all startup scripts and Runit services.

For example, here's how you can define an environment variable from your Dockerfile:

RUN echo Apachai Hopachai > /etc/container_environment/MY_NAME

You can verify that it works, as follows:

$ docker run -t -i <YOUR_NAME_IMAGE> /sbin/my_init -- bash -l
...
*** Running bash -l...
# echo $MY_NAME
Apachai Hopachai

Handling newlines

If you've looked carefully, you'll notice that the 'echo' command actually prints a newline. Why does $MY_NAME not contain a newline then? It's because my_init strips the trailing newline. If you intended on the value having a newline, you should add another newline, like this:

RUN echo -e "Apachai Hopachai\n" > /etc/container_environment/MY_NAME

Environment variable dumps

While the previously mentioned mechanism is good for centrally defining environment variables, itself does not prevent services (e.g. Nginx) from changing and resetting environment variables from child processes. However, the my_init mechanism does make it easy for you to query what the original environment variables are.

During startup, right after importing environment variables from /etc/container_environment, my_init will dump all its environment variables (that is, all variables imported from container_environment, as well as all variables it picked up from docker run --env) to the following locations, in the following formats:

  • /etc/container_environment
  • /etc/container_environment.sh - a dump of the environment variables in Bash format. You can source the file directly from a Bash shell script.
  • /etc/container_environment.json - a dump of the environment variables in JSON format.

The multiple formats make it easy for you to query the original environment variables no matter which language your scripts/apps are written in.

Here is an example shell session showing you how the dumps look like:

$ docker run -t -i \
  --env FOO=bar --env HELLO='my beautiful world' \
  phusion/baseimage:<VERSION> /sbin/my_init -- \
  bash -l
...
*** Running bash -l...
# ls /etc/container_environment
FOO  HELLO  HOME  HOSTNAME  PATH  TERM  container
# cat /etc/container_environment/HELLO; echo
my beautiful world
# cat /etc/container_environment.json; echo
{"TERM": "xterm", "container": "lxc", "HOSTNAME": "f45449f06950", "HOME": "/root", "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "FOO": "bar", "HELLO": "my beautiful world"}
# source /etc/container_environment.sh
# echo $HELLO
my beautiful world

Modifying environment variables

It is even possible to modify the environment variables in my_init (and therefore the environment variables in all child processes that are spawned after that point in time), by altering the files in /etc/container_environment. After each time my_init runs a startup script, it resets its own environment variables to the state in /etc/container_environment, and re-dumps the new environment variables to container_environment.sh and container_environment.json.

But note that:

  • modifying container_environment.sh and container_environment.json has no effect.
  • Runit services cannot modify the environment like that. my_init only activates changes in /etc/container_environment when running startup scripts.

Security

Because environment variables can potentially contain sensitive information, /etc/container_environment and its Bash and JSON dumps are by default owned by root, and accessible only to the docker_env group (so that any user added this group will have these variables automatically loaded).

If you are sure that your environment variables don't contain sensitive data, then you can also relax the permissions on that directory and those files by making them world-readable:

RUN chmod 755 /etc/container_environment
RUN chmod 644 /etc/container_environment.sh /etc/container_environment.json

System logging

Baseimage-docker uses syslog-ng to provide a syslog facility to the container. Syslog-ng is not managed as an runit service (see below). Syslog messages are forwarded to the console.

Log startup/shutdown sequence

In order to ensure that all application log messages are captured by syslog-ng, syslog-ng is started separately before the runit supervisor process, and shutdown after runit exits. This uses the startup script facility provided by this image. This avoids a race condition which would exist if syslog-ng were managed as an runit service, where runit kills syslog-ng in parallel with the container's other services, causing log messages to be dropped during a graceful shutdown if syslog-ng exits while logs are still being produced by other services.

Upgrading the operating system inside the container

Baseimage-docker images contain an Ubuntu operating system (see OS version at Overview). You may want to update this OS from time to time, for example to pull in the latest security updates. OpenSSL is a notorious example. Vulnerabilities are discovered in OpenSSL on a regular basis, so you should keep OpenSSL up-to-date as much as you can.

While we release Baseimage-docker images with the latest OS updates from time to time, you do not have to rely on us. You can update the OS inside Baseimage-docker images yourself, and it is recommended that you do this instead of waiting for us.

To upgrade the OS in the image, run this in your Dockerfile:

RUN apt-get update && apt-get upgrade -y -o Dpkg::Options::="--force-confold"

Container administration

One of the ideas behind Docker is that containers should be stateless, easily restartable, and behave like a black box. However, you may occasionally encounter situations where you want to login to a container, or to run a command inside a container, for development, inspection and debugging purposes. This section describes how you can administer the container for those purposes.

Running a one-shot command in a new container

Note: This section describes how to run a command insider a -new- container. To run a command inside an existing running container, see Running a command in an existing, running container.

Normally, when you want to create a new container in order to run a single command inside it, and immediately exit after the command exits, you invoke Docker like this:

docker run YOUR_IMAGE COMMAND ARGUMENTS...

However the downside of this approach is that the init system is not started. That is, while invoking COMMAND, important daemons such as cron and syslog are not running. Also, orphaned child processes are not properly reaped, because COMMAND is PID 1.

Baseimage-docker provides a facility to run a single one-shot command, while solving all of the aforementioned problems. Run a single command in the following manner:

docker run YOUR_IMAGE /sbin/my_init -- COMMAND ARGUMENTS ...

This will perform the following:

  • Runs all system startup files, such as /etc/my_init.d/* and /etc/rc.local.
  • Starts all runit services.
  • Runs the specified command.
  • When the specified command exits, stops all runit services.

For example:

$ docker run phusion/baseimage:<VERSION> /sbin/my_init -- ls
*** Running /etc/rc.local...
*** Booting runit daemon...
*** Runit started as PID 80
*** Running ls...
bin  boot  dev  etc  home  image  lib  lib64  media  mnt  opt  proc  root  run  sbin  selinux  srv  sys  tmp  usr  var
*** ls exited with exit code 0.
*** Shutting down runit daemon (PID 80)...
*** Killing all processes...

You may find that the default invocation is too noisy. Or perhaps you don't want to run the startup files. You can customize all this by passing arguments to my_init. Invoke docker run YOUR_IMAGE /sbin/my_init --help for more information.

The following example runs ls without running the startup files and with less messages, while running all runit services:

$ docker run phusion/baseimage:<VERSION> /sbin/my_init --skip-startup-files --quiet -- ls
bin  boot  dev  etc  home  image  lib  lib64  media  mnt  opt  proc  root  run  sbin  selinux  srv  sys  tmp  usr  var

Running a command in an existing, running container

There are two ways to run a command inside an existing, running container.

Both way have their own pros and cons, which you can learn in their respective subsections.

Login to the container, or running a command inside it, via docker exec

You can use the docker exec tool on the Docker host OS to login to any container that is based on baseimage-docker. You can also use it to run a command inside a running container. docker exec works by using Linux kernel system calls.

Here's how it compares to using SSH to login to the container or to run a command inside it:

  • Pros
    • Does not require running an SSH daemon inside the container.
    • Does not require setting up SSH keys.
    • Works on any container, even containers not based on baseimage-docker.
  • Cons
    • If the docker exec process on the host is terminated by a signal (e.g. with the kill command or even with Ctrl-C), then the command that is executed by docker exec is not killed and cleaned up. You will either have to do that manually, or you have to run docker exec with -t -i.
    • Requires privileges on the Docker host to be able to access the Docker daemon. Note that anybody who can access the Docker daemon effectively has root access.
    • Not possible to allow users to login to the container without also letting them login to the Docker host.

Usage

Start a container:

docker run YOUR_IMAGE

Find out the ID of the container that you just ran:

docker ps

Now that you have the ID, you can use docker exec to run arbitrary commands in the container. For example, to run echo hello world:

docker exec YOUR-CONTAINER-ID echo hello world

To open a bash session inside the container, you must pass -t -i so that a terminal is available:

docker exec -t -i YOUR-CONTAINER-ID bash -l

Login to the container, or running a command inside it, via SSH

You can use SSH to login to any container that is based on baseimage-docker. You can also use it to run a command inside a running container.

Here's how it compares to using docker exec to login to the container or to run a command inside it:

  • Pros
    • Does not require root privileges on the Docker host.
    • Allows you to let users login to the container, without letting them login to the Docker host. However, this is not enabled by default because baseimage-docker does not expose the SSH server to the public Internet by default.
  • Cons
    • Requires setting up SSH keys. However, baseimage-docker makes this easy for many cases through a pregenerated, insecure key. Read on to learn more.

Enabling SSH

Baseimage-docker disables the SSH server by default. Add the following to your Dockerfile to enable it:

RUN rm -f /etc/service/sshd/down

# Regenerate SSH host keys. baseimage-docker does not contain any, so you
# have to do that yourself. You may also comment out this instruction; the
# init system will auto-generate one during boot.
RUN /etc/my_init.d/00_regen_ssh_host_keys.sh

Alternatively, to enable sshd only for a single instance of your container, create a folder with a startup script. The contents of that should be

### In myfolder/enable_ssh.sh (make sure this file is chmod +x):
#!/bin/sh
rm -f /etc/service/sshd/down
ssh-keygen -P "" -t dsa -f /etc/ssh/ssh_host_dsa_key

Then, you can start your container with

docker run -d -v `pwd`/myfolder:/etc/my_init.d my/dockerimage

This will initialize sshd on container boot. You can then access it with the insecure key as below, or using the methods to add a secure key. Further, you can publish the port to your machine with -p 2222:22 allowing you to ssh to 127.0.0.1:2222 instead of looking up the ip address of the container.

About SSH keys

First, you must ensure that you have the right SSH keys installed inside the container. By default, no keys are installed, so nobody can login. For convenience reasons, we provide a pregenerated, insecure key (PuTTY format) that you can easily enable. However, please be aware that using this key is for convenience only. It does not provide any security because this key (both the public and the private side) is publicly available. In production environments, you should use your own keys.

Using the insecure key for one container only

You can temporarily enable the insecure key for one container only. This means that the insecure key is installed at container boot. If you docker stop and docker start the container, the insecure key will still be there, but if you use docker run to start a new container then that container will not contain the insecure key.

Start a container with --enable-insecure-key:

docker run YOUR_IMAGE /sbin/my_init --enable-insecure-key

Find out the ID of the container that you just ran:

docker ps

Once you have the ID, look for its IP address with:

docker inspect -f "{{ .NetworkSettings.IPAddress }}" <ID>

Now that you have the IP address, you can use SSH to login to the container, or to execute a command inside it:

# Download the insecure private key
curl -o insecure_key -fSL https://github.com/phusion/baseimage-docker/raw/master/image/services/sshd/keys/insecure_key
chmod 600 insecure_key

# Login to the container
ssh -i insecure_key root@<IP address>

# Running a command inside the container
ssh -i insecure_key root@<IP address> echo hello world

Enabling the insecure key permanently

It is also possible to enable the insecure key in the image permanently. This is not generally recommended, but is suitable for e.g. temporary development or demo environments where security does not matter.

Edit your Dockerfile to install the insecure key permanently:

RUN /usr/sbin/enable_insecure_key

Instructions for logging into the container is the same as in section Using the insecure key for one container only.

Using your own key

Edit your Dockerfile to install an SSH public key:

## Install an SSH of your choice.
COPY your_key.pub /tmp/your_key.pub
RUN cat /tmp/your_key.pub >> /root/.ssh/authorized_keys && rm -f /tmp/your_key.pub

Then rebuild your image. Once you have that, start a container based on that image:

docker run your-image-name

Find out the ID of the container that you just ran:

docker ps

Once you have the ID, look for its IP address with:

docker inspect -f "{{ .NetworkSettings.IPAddress }}" <ID>

Now that you have the IP address, you can use SSH to login to the container, or to execute a command inside it:

# Login to the container
ssh -i /path-to/your_key root@<IP address>

# Running a command inside the container
ssh -i /path-to/your_key root@<IP address> echo hello world

The docker-ssh tool

Looking up the IP of a container and running an SSH command quickly becomes tedious. Luckily, we provide the docker-ssh tool which automates this process. This tool is to be run on the Docker host, not inside a Docker container.

First, install the tool on the Docker host:

curl --fail -L -O https://github.com/phusion/baseimage-docker/archive/master.tar.gz && \
tar xzf master.tar.gz && \
sudo ./baseimage-docker-master/install-tools.sh

Then run the tool as follows to login to a container using SSH:

docker-ssh YOUR-CONTAINER-ID

You can lookup YOUR-CONTAINER-ID by running docker ps.

By default, docker-ssh will open a Bash session. You can also tell it to run a command, and then exit:

docker-ssh YOUR-CONTAINER-ID echo hello world

Building the image yourself

If for whatever reason you want to build the image yourself instead of downloading it from the Docker registry, follow these instructions.

Clone this repository:

git clone https://github.com/phusion/baseimage-docker.git
cd baseimage-docker

Start a virtual machine with Docker in it. You can use the Vagrantfile that we've already provided.

First, install vagrant-disksize plug-in:

vagrant plugin install vagrant-disksize:

Then, start the virtual machine

vagrant up
vagrant ssh
cd /vagrant

Build the image:

make build

If you want to call the resulting image something else, pass the NAME variable, like this:

make build NAME=joe/baseimage

You can also change the ubuntu base-image to debian as these distributions are quite similar.

make build BASE_IMAGE=debian:stretch

The image will be: phusion/baseimage-debian-stretch. Use the NAME variable in combination with the BASE_IMAGE one to call it joe/stretch.

make build BASE_IMAGE=debian:stretch NAME=joe/stretch

To verify that the various services are started, when the image is run as a container, add test to the end of your make invocations, e.g.:

make build BASE_IMAGE=debian:stretch NAME=joe/stretch test

Removing optional services

The default baseimage-docker installs syslog-ng, cron and sshd services during the build process.

In case you don't need one or more of these services in your image, you can disable its installation through the image/buildconfig that is sourced within image/system_services.sh. Do this at build time by passing a variable in with --build-arg as in docker build --build-arg DISABLE_SYSLOG=1 image/, or you may set the variable in image/Dockerfile with an ENV setting above the RUN directive.

These represent build-time configuration, so setting them in the shell env at build-time will not have any effect. Setting them in child images' Dockerfiles will also not have any effect.)

You can also set them directly as shown in the following example, to prevent sshd from being installed into your image, set 1 to the DISABLE_SSH variable in the ./image/buildconfig file.

### In ./image/buildconfig
# ...
# Default services
# Set 1 to the service you want to disable
export DISABLE_SYSLOG=0
export DISABLE_SSH=1
export DISABLE_CRON=0

Then you can proceed with make build command.

Conclusion

  • Using baseimage-docker? Tweet about us or follow us on Twitter.
  • Having problems? Want to participate in development? Please post a message at the discussion forum.
  • Looking for a more complete base image, one that is ideal for Ruby, Python, Node.js and Meteor web apps? Take a look at passenger-docker.
  • Need a helping hand? Phusion also offers consulting on a wide range of topics, including Web Development, UI/UX Research & Design, Technology Migration and Auditing.

Please enjoy baseimage-docker, a product by Phusion. :-)

baseimage-docker's People

Contributors

amitie10g avatar camjn avatar codecutteruk avatar davidhiendl avatar djdembeck avatar endersonmaia avatar floord avatar foobarwidget avatar hyperknot avatar imanel avatar jedie avatar josegonzalez avatar jsravn avatar kamermans avatar liushooter avatar matyasmarkovics avatar mpeterson avatar mrserth avatar ohcoder avatar rdxmb avatar rwky avatar samip5 avatar smola avatar sundbry avatar szemek avatar temoto avatar tgranqvist avatar theaxiom avatar thomasleveil avatar yebyen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

baseimage-docker's Issues

Insertion failed because database is full: database or disk is full

OK so I am provisioning an analysis image and I have just hit an error :

➜  cloudbiolinux  sudo docker build -t szbifx/ai:0.1 .
Uploading context 43.01 kB
Uploading context
Step 0 : FROM phusion/baseimage
 ---> 745d3ac92697
Step 1 : MAINTAINER Timothy Laurent
 ---> Using cache
 ---> 5a3ca3a81560
Step 2 : RUN apt-get update && apt-get install -y -q git build-essential autotools-dev automake pkg-config curl wget && apt-get clean
 ---> Using cache
 ---> 4dab4dcba94d
Step 3 : RUN mkdir /install && cd install ;    apt-get update ; apt-get install python-setuptools python-dev -y -q && apt-get clean
2014/04/30 09:54:25 Insertion failed because database is full: database or disk is full

docker info shows :

➜  cloudbiolinux  sudo docker info
Containers: 54
Images: 80
Storage Driver: devicemapper
 Pool Name: docker-8:21-656129-pool
 Data file: /var/lib/docker/devicemapper/devicemapper/data
 Metadata file: /var/lib/docker/devicemapper/devicemapper/metadata
 Data Space Used: 0.0 Mb
 Data Space Total: 0.0 Mb
 Metadata Space Used: 0.0 Mb
 Metadata Space Total: 0.0 Mb
Execution Driver: native-0.1
Kernel Version: 3.8.0-39-generic
WARNING: No swap limit support

OK so what happened to the devicemapper space?

Yesterday I hit the 10GB limit for devicemapper. I can't wait until that limit is gone. But not it looks like I don't have any space.

What is going on here??

add-apt-repository fail

Probably not a baseimage bug in the line of ca-certificates missings but fail ...

Dockerfile

# nas
# VERSION 0.1.9

FROM phusion/baseimage:0.9.10
MAINTAINER bySabi <[email protected]>

RUN \
    apt-get update 1>/dev/null && apt-get upgrade -y -q --no-install-recommends && \
    apt-get install -y --no-install-recommends python-software-properties ca-certificates

RUN add-apt-repository -y ppa:nginx/stable

Fail with:

/bin/sh: 1: add-apt-repository: not found

Any sugesstion to solved?

my_init doesn't preserve non-zero exit status

Unless I'm misunderstanding something, the final line of this output should read 42:

$ docker run --rm phusion/baseimage:0.9.9 /sbin/my_init --skip-runit -- bash -c 'exit 42'
*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
No SSH host key available. Generating one...
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
Creating SSH2 ECDSA key; this may take some time ...
*** Running /etc/rc.local...
*** Running bash -c exit 42...
*** bash exited with exit code 10752.
*** Killing all processes...
$ echo $?
0

How to run one or two commands?

I tried this and it works:

docker run -i -t myimage my_init -- echo 'lol'

But then I tried this and didn't work:

$ docker run -i -t myimage my_init -- cd /srv
cd exited with exit code 32512

What I really want to do is go to certain directory and then execute certain script (the script uses relative paths so I can't execute it directly, I have to cd to the directory first). The cd part already is supposed to happen in ~/.bashrc, but apparently it hasn't been executed yet. Is there a way to make my command execute after ~/.bashrc? If that's not possible, I would like to simply run two commands: cd into that directory and then execute the script.

Support for Ubuntu 14.04 LTS

hello,
do you guys got a plan to migrate this base image to newest Ubuntu LTS version ?
Apart from that - well done. This image is exactly what I was looking for.

Regards,
Robert

weird problem

The dockerfile below crashes after I uncomment these 4 lines shown below in the docker file:

#RUN touch "/etc/php5/fpm/conf.d/20-mongo.ini"
#RUN touch "/etc/php5/cli/conf.d/20-mongo.ini"
#RUN echo "extension=mongo.so" >> /etc/php5/fpm/conf.d/20-mongo.ini
#RUN echo "extension=mongo.so" >> /etc/php5/cli/conf.d/20-mongo.ini

here:

FROM phusion/baseimage:0.9.9

ENV HOME /root

RUN /etc/my_init.d/00_regen_ssh_host_keys.sh

CMD ["/sbin/my_init"]

# Some Environment Variables
ENV    DEBIAN_FRONTEND noninteractive

# Nginx-PHP Installation
RUN apt-get update
RUN apt-get install -y vim curl wget build-essential python-software-properties
RUN add-apt-repository -y ppa:ondrej/php5
RUN add-apt-repository -y ppa:nginx/stable
RUN apt-get update
RUN apt-get install -y php-pear php5-dev php5-cli php5-fpm php5-mysql php5-pgsql \
            php5-sqlite php5-curl php5-gd php5-mcrypt php5-intl php5-imap php5-tidy
RUN yes '' | pecl install mongo
RUN touch "/etc/php5/fpm/conf.d/20-mongo.ini"
RUN touch "/etc/php5/cli/conf.d/20-mongo.ini"
RUN echo "extension=mongo.so" >> /etc/php5/fpm/conf.d/20-mongo.ini
RUN echo "extension=mongo.so" >> /etc/php5/cli/conf.d/20-mongo.ini

RUN sed -i "s/;date.timezone =.*/date.timezone = UTC/" /etc/php5/fpm/php.ini
RUN sed -i "s/;date.timezone =.*/date.timezone = UTC/" /etc/php5/cli/php.ini

RUN apt-get install -y nginx

RUN echo "daemon off;" >> /etc/nginx/nginx.conf
RUN sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php5/fpm/php-fpm.conf
RUN sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php5/fpm/php.ini

RUN mkdir           /var/www
ADD build/default   /etc/nginx/sites-available/default
RUN mkdir           /etc/service/nginx
ADD build/nginx.sh  /etc/service/nginx/run
RUN chmod +x        /etc/service/nginx/run
RUN mkdir           /etc/service/phpfpm
ADD build/phpfpm.sh /etc/service/phpfpm/run
RUN chmod +x        /etc/service/phpfpm/run

EXPOSE 80
EXPOSE 81
# End Nginx-PHP

RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

why when running such a container would crash? can someone please explain?

setuser problem

Hi,

I think there is a problem with the setuser tool... I used it to start a redis server, and some other services, but after updating to latest baseimage it won't work anymore.

root@0aebe605108e:/# /sbin/setuser redis /usr/bin/redis-server /etc/redis/redis.conf
setuser: cannot execute /usr/bin/redis-server: [Errno 13] Permission denied

permissions look good for me .. and using su to change the user and start the server manually works.

Add anacron to the system services

As the docker containers aren't always up all time, particularly on the dev side, I find it convenient to have anacron making sure that cronjobs are executed once in a while, for example for log rotations, etc.

I've modified image/system_services.sh to add "$minimal_apt_get_install anacron" in my "Debian fork" (https://github.com/olberger/baseimage-docker/tree/debian).

Or maybe this is only useful in Debian environment, and not applying to the base Ubuntu system ?

Hope this helps.

cannot pull phusion/baseimage

Possibly a docker index issue, I don't know. I'm running docker on ubuntu 13.10 on esxi 5.1 on a speedy fiber connection in canada

"docker pull phusion/baseimage" fails over and over

Pulling repository phusion/baseimage
65e9dbc42589: Error pulling image (latest) from phusion/baseimage, link /opt/docker_runtime/docker/devicemapper/mnt/444041ffab2cdeced4f5254da0680282055f768e64cc6e77c31b921160e980e2/rootfs/.wh..wh.plnk/317.929004a9f93affd469: Download complete 
99e64f286549: Download complete 
8dbd9e392a96: Download complete 
15fda1f601cb: Download complete 
a092c0d9e4a9: Download complete 
5ba4bd3b42b5: Download complete 
87081acac42d: Download complete 
444041ffab2c: Error downloading dependent layers 
8b4daf651a99: Download complete 
27a4ee5782fb: Download complete 
b45f1125208a: Download complete 
1430b0dcd3fc: Download complete 
816b6817e295: Download complete 
0112363aa85e: Download complete 
a19f2a8d5b34: Download complete 
b1f6df7052a1: Download complete 
dc5551da37ca: Download complete 
7be9d12a2177: Download complete 
afe99d7ac3c2: Download complete 
7228d468b63c: Download complete 
2014/01/15 17:45:14 Could not find repository on any of the indexed registries.

my_init is not waitpid'ing correctly

My_init's waitpid algorithm currently involves waiting for any child process, until the requested child process is waited for. This normally works well, but not when my_init has to wait for multiple processes, such as when shutting down Runit. The wait for a non-Runit process could have reaped Runit, causing a future wait for Runit to fail.

Missing link environment variables

It looks like the environment variables set when linking a container are not available when using your image. Information on the docker site:

http://docs.docker.io/en/latest/use/working_with_links_names/

I use these in my rails app container database.yml script.

e.g.

defaults: &defaults
  adapter: postgresql
  host: <%= ENV['POSTGRES_PORT_5432_TCP_ADDR'] %>
  port: <%= ENV['POSTGRES_PORT_5432_TCP_PORT'] %>
  username: docker
  password: docker

development:
  <<: *defaults
  database: db_development

test:
  <<: *defaults
  database: db_test

production:
  <<: *defaults
  database: db_production

Release 0.9.10 not CA certificates

I think, in some point 0.9.10 image lost ca-certificates. Now I have to add:
apt-get install ca-certificates to Dockerfile for properly fetch https urls.

Permission denied errors

I'm having some trouble with phusion/baseimage resulting in "Permission denied" errors. Here's an example:

 docker run --rm -it phusion/baseimage:0.9.9 /sbin/my_init -- bash
*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
No SSH host key available. Generating one...
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
Creating SSH2 ECDSA key; this may take some time ...
*** Running /etc/rc.local...
*** Booting runit daemon...
*** Runit started as PID 74
*** Running bash...
root@993e4c770d14:/# addgroup --gid 9999 app && adduser --uid 9999 --gid 9999 --disabled-password --gecos "Application" app && usermod -L app
Adding group `app' (GID 9999) ...
Done.
Adding user `app' ...
Adding new user `app' (9999) with group `app' ...
Creating home directory `/home/app' ...
Copying files from `/etc/skel' ...

root@993e4c770d14:/# setuser app touch /tmp/foo
touch: cannot touch `/tmp/foo': Permission denied

root@993e4c770d14:/# setuser app bash -c 'echo foo > /dev/null'
bash: /dev/null: Permission denied

As you can see, after booting a container, a new non-root user is unable to create a file in /tmp or write to /dev/null.

Any ideas? Thanks.

my_init should have a mechanism to wait until all Runit services are started

I'm having around 300 images based on baseimage-docker and I'm running a script that will run a command on each of those (with /sbin/my_init -- as an entry point), wait for it to finish, do stuff, run next...

Several times, container hang with this message as last thing in log:

warning: /etc/service/cron: unable to open supervise/ok: file does not exist

except any of the cron / syslog / ssh could fail with this message.

I'm not having a reliable way to reproduce this.

Vagrant "There are errors in the configuration of this machine"

I may be being utterly stupid here, as I'm struggling to get to grips with Docker on OSX and am having to use Vagrant to do so. I think this'd be much easier with Vagrant out of the mix, but that isn't an option for me.

I assumed that I could just download this repository, navigate into the directory, and run

vagrant up --provider=docker

As there's a Vagrantfile included in the repo. But if I do I get the following output:

Bringing machine 'default' up with 'docker' provider...
There are errors in the configuration of this machine. Please fix
the following errors and try again:

docker provider:
* One of "build_dir" or "image" must be set

I'm running Vagrant 1.6.3.

I'd originally tried following the Vagrant blog post ( http://www.vagrantup.com/blog/feature-preview-vagrant-1-6-docker-dev-environments.html ) but that doesn't work either, it appears that the phusion.key isn't something that 'just exists' and I've not been able to follow how to get any Docker environment up and running via Vagrant with SSH support.

Store environment variables in a file, and allow init scripts to change environment variables

Since processes such as Nginx nuke environment variables, we will want to provide an easy way for processes to query what the original environment variables are. my_init should store the original environment variable in files, ideally in multiple formats so that applications can easily parse them:

We should also allow init scripts in the startup pipeline to modify the environment for subsequent scripts. They can write to the flat files in /etc/container_environment. My_init will then import them, and export them to the bash and json formats before continuing.

SSH does not preserve ENV variables

Dockfile used for test:

FROM phusion/baseimage:0.9.9

ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8
ENV LC_ALL en_US.UTF-8

RUN /etc/my_init.d/00_regen_ssh_host_keys.sh && \
    rm /etc/my_init.d/00_regen_ssh_host_keys.sh

RUN /usr/sbin/enable_insecure_key

CMD ["/sbin/my_init"]

Testing via docker run

$ docker run -i e38194b7ec6f my_init -- env
*** Running /etc/rc.local...
*** Booting runit daemon...
*** Runit started as PID 8
*** Running env...
LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8
HOSTNAME=97b73766a684
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
INITRD=no
LC_ALL=en_US.UTF-8
HOME=/root
*** env exited with exit code 0.
*** Shutting down runit daemon (PID 8)...
*** Killing all processes...

Testing via ssh execute

$ ssh [email protected] env
SHELL=/bin/bash
SSH_CLIENT=172.17.42.1 37381 22
USER=root
MAIL=/var/mail/root
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11
PWD=/root
SHLVL=1
HOME=/root
LOGNAME=root
SSH_CONNECTION=172.17.42.1 37381 172.17.0.2 22
_=/usr/bin/env

Testing via ssh -> env

$ ssh [email protected]
Welcome to Ubuntu 12.04.4 LTS (GNU/Linux 3.8.0-35-generic x86_64)

 * Documentation:  https://help.ubuntu.com/
root@83fc7ad57eaf:~# env
TERM=xterm-256color
SHELL=/bin/bash
SSH_CLIENT=172.17.42.1 37382 22
SSH_TTY=/dev/pts/0
USER=root
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:d... <cut>
MAIL=/var/mail/root
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11
PWD=/root
SHLVL=1
HOME=/root
LOGNAME=root
SSH_CONNECTION=172.17.42.1 37382 172.17.0.2 22
LESSOPEN=| /usr/bin/lesspipe %s
LESSCLOSE=/usr/bin/lesspipe %s %s
_=/usr/bin/env

Expected behavior

Env variables set via Dockerfile or container environments.

apt-get update fail: Related to https://github.com/phusion/baseimage-docker/issues/72

Is not so simple ...

Case 1:

    ...
    RUN echo "deb https://download.sernet.de/packages/samba/4.1/ubuntu trusty main"  >> /etc/apt/source.list
    RUN apt-get update
    ...

apt-get update fail cause can´t fetch https urls.

Case 2:

curl or wget any https://...  fail too.

if not a good behaviour remember add: apt-get install ca-certificates for basis thing like add/download secured content. Today everywhere is moving to secures URL´s

Is was OK on precise by default.

dependency on python2?

does this library has a dependency on python2?

i get when i try to run this docker run --rm -t -i phusion/baseimage /sbin/my_init -- bash -l

/usr/bin/python2: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

adding service logrotate ?

I have yet no experience with long running container based on phusion/baseimage, but I wonder if some of the log files might grow beyond reasonable.

Would not installing logrotate by default be wise ?

Conflicting docs

At http://phusion.github.io/baseimage-docker/ this paragraph

setuser
A custom tool for running a command as another user. Easier to use than su, has a smaller attack vector than sudo, and unlike chpst this tool sets $HOME correctly. Available as /sbin/setuser.

and this example

### In memcached.sh (make sure this file is chmod +x):
#!/bin/sh
# `chpst` is part of running. `chpst -u memcache` runs the given command
# as the user `memcache`. If you omit this, the command will be run as root.
exec chpst -u memcache /usr/bin/memcached >>/var/log/memcached.log 2>&1

look a bit in contrast. I suspect the example is outdated.

(And does runit kick in automatically?)

exposed port 80 and 443

I wonder why are ports 80 and 443 exposed in the Dockerfile.
Is this a mistake or is there any undocumented feature behind those ports ?

0.9.9 | apt-get install | Failed to fetch

I want to use 0.9.9 because with 0.9.10 a program that I use gives fatal error on compilation. With 0.9.9 it sure worked, I installed in about 3 moths ago.
Now I made some changes in my Dockerfile, tried to build it, but it gives me "Failed to fetch" errors.

Step 8 : RUN apt-get install -y --fix-missing mysql-server
 ---> Running in a68e51246702
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
  libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18
  libnet-daemon-perl libplrpc-perl libterm-readkey-perl mysql-client-5.5
  mysql-client-core-5.5 mysql-common mysql-server-5.5 mysql-server-core-5.5
Suggested packages:
  libipc-sharedcache-perl tinyca mailx
The following NEW packages will be installed:
  libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18
  libnet-daemon-perl libplrpc-perl libterm-readkey-perl mysql-client-5.5
  mysql-client-core-5.5 mysql-common mysql-server mysql-server-5.5
  mysql-server-core-5.5
0 upgraded, 13 newly installed, 0 to remove and 10 not upgraded.
Need to get 27.2 MB of archives.
After this operation, 97.5 MB of additional disk space will be used.
Err http://archive.ubuntu.com/ubuntu/ precise-updates/main mysql-common all 5.5.35-0ubuntu0.12.04.2
  404  Not Found [IP: 91.189.92.200 80]
Err http://archive.ubuntu.com/ubuntu/ precise-updates/main libmysqlclient18 amd64 5.5.35-0ubuntu0.12.04.2
  404  Not Found [IP: 91.189.92.200 80]
Get:1 http://archive.ubuntu.com/ubuntu/ precise/main libnet-daemon-perl all 0.48-1 [43.1 kB]
Get:2 http://archive.ubuntu.com/ubuntu/ precise/main libplrpc-perl all 0.2020-2 [36.0 kB]
Get:3 http://archive.ubuntu.com/ubuntu/ precise/main libdbi-perl amd64 1.616-1build2 [849 kB]
Get:4 http://archive.ubuntu.com/ubuntu/ precise/main libdbd-mysql-perl amd64 4.020-1build2 [106 kB]
Err http://archive.ubuntu.com/ubuntu/ precise-updates/main mysql-client-core-5.5 amd64 5.5.35-0ubuntu0.12.04.2
  404  Not Found [IP: 91.189.92.200 80]
Get:5 http://archive.ubuntu.com/ubuntu/ precise/main libterm-readkey-perl amd64 2.30-4build3 [28.6 kB]
Err http://archive.ubuntu.com/ubuntu/ precise-updates/main mysql-client-5.5 amd64 5.5.35-0ubuntu0.12.04.2
  404  Not Found [IP: 91.189.92.200 80]
Err http://archive.ubuntu.com/ubuntu/ precise-updates/main mysql-server-core-5.5 amd64 5.5.35-0ubuntu0.12.04.2
  404  Not Found [IP: 91.189.92.200 80]
Err http://archive.ubuntu.com/ubuntu/ precise-updates/main mysql-server-5.5 amd64 5.5.35-0ubuntu0.12.04.2
  404  Not Found [IP: 91.189.92.200 80]
Get:6 http://archive.ubuntu.com/ubuntu/ precise/main libhtml-template-perl all 2.10-1 [65.0 kB]
Err http://archive.ubuntu.com/ubuntu/ precise-updates/main mysql-server all 5.5.35-0ubuntu0.12.04.2
  404  Not Found [IP: 91.189.92.200 80]
Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/m/mysql-5.5/mysql-common_5.5.35-0ubuntu0.12.04.2_all.deb  404  Not Found [IP: 91.189.92.200 80]
Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/m/mysql-5.5/libmysqlclient18_5.5.35-0ubuntu0.12.04.2_amd64.deb  404  Not Found [IP: 91.189.92.200 80]
Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/m/mysql-5.5/mysql-client-core-5.5_5.5.35-0ubuntu0.12.04.2_amd64.deb  404  Not Found [IP: 91.189.92.200 80]
Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/m/mysql-5.5/mysql-client-5.5_5.5.35-0ubuntu0.12.04.2_amd64.deb  404  Not Found [IP: 91.189.92.200 80]
Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/m/mysql-5.5/mysql-server-core-5.5_5.5.35-0ubuntu0.12.04.2_amd64.deb  404  Not Found [IP: 91.189.92.200 80]
Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/m/mysql-5.5/mysql-server-5.5_5.5.35-0ubuntu0.12.04.2_amd64.deb  404  Not Found [IP: 91.189.92.200 80]
Failed to fetch http://archive.ubuntu.com/ubuntu/pool/main/m/mysql-5.5/mysql-server_5.5.35-0ubuntu0.12.04.2_all.deb  404  Not Found [IP: 91.189.92.200 80]
Fetched 1127 kB in 0s (1588 kB/s)
Unable to correct missing packages.
E: Aborting install.
2014/06/02 09:14:26 The command [/bin/sh -c apt-get install -y --fix-missing mysql-server] returned a non-zero code: 100

Log in without keys

I am using the baseimage to create a bioinformatics analysis images that we can run on bare metal, vms, or in the cloud. I have added the core users in the dockerfile and now I would like to allow these users to log in without a key -- you know, with just their password

everytime I try to do this I get this

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
cd:3a:28:db:45:d7:43:de:9f:37:6a:4a:8e:34:39:85.
Please contact your system administrator.
Add correct host key in /home/tlaurent/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/tlaurent/.ssh/known_hosts:17
  remove with: ssh-keygen -f "/home/tlaurent/.ssh/known_hosts" -R 172.17.0.2
ECDSA host key for 172.17.0.2 has changed and you have requested strict checking.
Host key verification failed.

Is there a good way I can make the system just be a container we can ssh into without
using key files?

How can I log runit messages to a log file?

Let's say I have a running service using the directory /etc/service/foo. Now I delete that directory. Runit will start showing a message (which can be seen with ps aux) saying it can't find that directory. But that message isn't logged anywhere. How can I do that? I couldn't find anything about this in runit's docs.

Btw, thanks for this great image, I'm loving it.

Getting tons of debconf messages unless TERM is set to linux

debconf: unable to initialize frontend: Dialog
debconf: (Dialog frontend will not work on a dumb terminal, an emacs shell buffer, or without a controlling terminal.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl .) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7, <> line 19.)
debconf: falling back to frontend: Teletype
dpkg-preconfigure: unable to re-open stdin:

`docker run` envs don't override those in `/etc/container_environment`

I'm trying to use /etc/container_environment as a way to bake "default" values for environment variables into a Docker image. I then want to optionally override these values using docker run --env=....

Consider the following Dockerfile:

FROM phusion/baseimage
RUN echo "foo" >/etc/container_environment/FOO

I use this to produce an image named env-test:

$ docker build -t env-test .

Then I can see that an env FOO is set within the container:

$ docker run --rm env-test my_init --skip-runit --quiet -- env 2>/dev/null | grep FOO
FOO=foo

When I attempt to provide a different value of FOO using the --env option for docker run, it doesn't override the original value:

$ docker run --rm --env FOO=bar env-test my_init --skip-runit --quiet -- env 2>/dev/null | grep FOO
FOO=foo

Is this expected? It seems incorrect to me.

my_init: OSError: [Errno 10] No child processes

I'm intermittently seeing this error:

++ docker run --rm image_name_here /sbin/my_init --quiet --skip-runit -- true
*** An error occurred. Aborting.
Traceback (most recent call last):
  File "/sbin/my_init", line 311, in <module>
    main(args)
  File "/sbin/my_init", line 259, in main
    exit_code = waitpid_reap_other_children(pid)
  File "/sbin/my_init", line 108, in waitpid_reap_other_children
    this_pid, status = os.waitpid(-1, 0)
OSError: [Errno 10] No child processes

Strange issue on trying to resolve smtp.office365.com

Hi,
I have a problem that's puzzling me: although I can ping and resolve smtp.office365.com from inside a container, using netcat just hangs indefinitely, apparently because it cannot resolve the domain name. This problem seems to occur only with that specific domain name. To reproduce:

docker run --rm -t -i ubuntu /bin/bash
ping smtp.office365.com # Ok
netcat smtp.office365.com 587 # Hangs, no messages
netcat 132.245.211.249 587 # (One of the IPs smtp.office365.com resolves to) Ok
netcat smtp.gmail.com # (for example) Ok

I can reach smtp.office365.com from the host or from a machine on a different network.

Can you reproduce this? What's going on? I don't even know how to debug this. Using Docker version 0.11.1, build fb99f99.

baseimage-docker based on newer ubuntu versions?

Any plans to provide baseimage-docker based on newer Ubuntu versions, e.g. the currently latest 13.10? I don't find the benefits of LTS compelling for containers.

Would forking this repo be the simplest path? And would you anticipate any major issues building this image based on ubuntu:13.10?

Thanks!

Environment not passed to runit scripts

Environment variables passed into the container via the -e option of docker run are not preserved through the runit launch process. I have confirmed that the variables are available to the /sbin/my_init process, but on line 75, you call /usr/sbin/runsvdir-start which clears the environment before calling runsvdir. My recommendation is to bypass runsvdir-start and call runsvdir directly in order to preserve the environment.

Trusted build

Not really an issue here but as many people where yelling for a trusted build on the page https://index.docker.io/u/phusion/baseimage/ , I created one on https://index.docker.io/u/gissehel/phusion-baseimage/ .

I named it "phusion-baseimage" because "phusion's baseimage" is the most meaningfull title I found. On the other hand, it contains the term "phusion" in it, which you may not like.

If this is a problem, I can delete the docker index's repo and github repo (for that reason or any other reason like you provided trusted builds, or you just don't like the idea).

/sbin/my_init: line 2: import: command not found

When i run my Dockerfile, i have this message

sudo docker run -rm -t -i -p 27017:27017 -v /var/data:/D -v /var/data/log:/L ng2/mongodb
Invalid command: /sbin/my_init

If i try to launch with

sudo docker run -rm -t -i -p 27017:27017 -v /var/data:/D -v /var/data/log:/L --entrypoint bash ng2/mongodb
/sbin/my_init: line 2: import: command not found
/sbin/my_init: line 4: KILL_PROCESS_TIMEOUT: command not found
/sbin/my_init: line 5: KILL_ALL_PROCESSES_TIMEOUT: command not found
/sbin/my_init: line 7: LOG_LEVEL_ERROR: command not found
/sbin/my_init: line 8: LOG_LEVEL_WARN: command not found
/sbin/my_init: line 9: LOG_LEVEL_INFO: command not found
/sbin/my_init: line 10: LOG_LEVEL_DEBUG: command not found
/sbin/my_init: line 12: log_level: command not found
/sbin/my_init: line 14: syntax error near unexpected token `('
/sbin/my_init: line 14: `class AlarmException(Exception):'

Docker version :

sudo docker version
Client version: 0.8.1
Go version (client): go1.2
Git commit (client): a1598d1
Server version: 0.8.1
Git commit (server): a1598d1
Go version (server): go1.2
Last stable version: 0.8.1

Let's get docker images :

sudo docker images
REPOSITORY               TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
ng2/mongodb              latest              09d620ea830d        3 minutes ago       595.5 MB
<none>                   <none>              0abb320eaa5c        7 minutes ago       595.5 MB
<none>                   <none>              b45ee8b7c78a        36 minutes ago      595.5 MB
<none>                   <none>              53d8f8bf98a5        2 days ago          595.2 MB
crosbymichael/dockerui   latest              1364a90139c5        2 days ago          467.4 MB
<none>                   <none>              374e0657b5cc        2 days ago          595.2 MB
<none>                   <none>              8d8a71e48513        2 days ago          595.2 MB
<none>                   <none>              ee5d2de85091        2 days ago          467.4 MB
phusion/baseimage        0.9.6               f4e6f8a8ae28        7 days ago          352.8 MB
phusion/baseimage        latest              f4e6f8a8ae28        7 days ago          352.8 MB
phusion/baseimage        0.9.5               a96ad6a18c43        2 weeks ago         352.8 MB
ubuntu                   12.04               9cd978db300e        2 weeks ago         204.4 MB
phusion/baseimage        0.9.4               f2e32dd503b7        2 weeks ago         403.8 MB
phusion/baseimage        0.9.1               a9f93affd469        3 months ago        346.9 MB
phusion/baseimage        0.9.0               99e64f286549        3 months ago        346.9 MB

And my Dockerfile is :

FROM phusion/baseimage:latest

MAINTAINER [email protected]

ENV HOME /root
ENV MONGO_VERSION 2.4.8

RUN /etc/my_init.d/00_regen_ssh_host_keys.sh

RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
RUN echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | tee /etc/apt/sources.list.d/mongodb.list
RUN apt-get -qq -y update
RUN rm /usr/sbin/policy-rc.d
RUN apt-get install -qq -y mongodb-10gen=$MONGO_VERSION

VOLUME ["/D", "/L"]
EXPOSE 27017

CMD ["/sbin/my_init"]

ENTRYPOINT ["mongod","-f","/D/mongodb.conf"]

Works fine with direct phusion/baseimage

sudo docker run -rm -t -i phusion/baseimage bash -l
root@86ff86b5cdc1:/# 

Environment not correct with v0.9.7

I just updated my Dockerfile to use baseimage-docker v0.9.7 instead of v0.9.6 (you can check the source here: https://github.com/StudioMelipone/docker-ruby-2.0.0-p353 and the image is available on the docker index) and now the script executed by my_init does not work anymore.
The problem seems to be a wrong environment since when bundler run, it complains about not finding git and other executables. Indeed when doing an env there are only two variables (PWD and OLD_PWD).

Possible to use upstart?

Is it still possible to use upstart services with this baseimage? I'd like to orchestrate/setup docker containers with ansible playbooks that already rely on upstart services.

Would that work oob or do I have to install/fix stuff in the image first?

enabling insecure key at runtime

I feel uncomfortable publishing a docker image based on baseimage with the insecure key enabled. However I would like end users to be able to easily enable the insecure key.

What about adding a new argument to my_init, let say --enable-insecure-key that would take care of that ?

/etc/my_init.d/logtime.sh failed with status 127

Your sample sh with chmod +x

#In logtime.sh (make sure this file is chmod +x):
#!/bin/bash
/bin/date > /tmp/boottime.txt

RUN mkdir -p /etc/my_init.d
ADD logtime.sh /etc/my_init.d/logtime.sh

docker run -i -t kunthar/middleware /sbin/my_init -- /bin/bash
*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
*** Running /etc/my_init.d/logtime.sh...
*** /etc/my_init.d/logtime.sh failed with status 127
*** Killing all processes...

Whenever i comment out

ADD logtime.sh /etc/my_init.d/logtime.sh

everything is fine.

This is the explanation of status 127= http://is.gd/eKCtRI
I've used

/bin/date > /tmp/boottime.txt

but no luck.

Any comments?

Can’t run an image based on baseimage-docker without arguments?

Hi,

I’m quite new to docker and I’m trying to create an example image to work with ruby on rails.
But when I’m trying to execute my script with my_init it doesn’t work.

I have the following entries in my Dockerfile:

ENTRYPOINT ["/sbin/my_init"]
CMD ["/root/rails.sh"]

When I try to run my image with docker run without any argument, I have the following error:
my_init: error: unrecognized arguments: -c #(nop) ADD file:19aa57293c80cb2b84047fcfcbc89cd75ded94e5841cc8062e282dca6e5e680e in /etc/service/redis/run

I tried to add "--" to CMD but with no luck. I don’t understand what’s the matter here?

SSH with docker 0.9: PTY allocation request failed on channel 0

Hi. When I run a baseimage-based container on docker 0.9 and try to ssh to it, I get the error:

PTY allocation request failed on channel 0
stdin: is not a tty

It seems like I still have a bash, but without prompt or anything. The same image worked as expected under docker-0.8.0. Nothing in syslog or docker -D output in response to the connection attempts.

ssh -v: (ssh -vvvv at http://bpaste.net/show/188386/)

voyd@kanne> ssh [email protected] -v
OpenSSH_6.5, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /home/voyd/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to 172.17.0.4 [172.17.0.4] port 22.
debug1: Connection established.
debug1: identity file /home/voyd/.ssh/id_rsa type 1
debug1: identity file /home/voyd/.ssh/id_rsa-cert type -1
debug1: identity file /home/voyd/.ssh/id_dsa type -1
debug1: identity file /home/voyd/.ssh/id_dsa-cert type -1
debug1: identity file /home/voyd/.ssh/id_ecdsa type -1
debug1: identity file /home/voyd/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/voyd/.ssh/id_ed25519 type -1
debug1: identity file /home/voyd/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.5
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.1 pat OpenSSH_5* compat 0x0c000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA cd:e9:52:a5:e3:61:51:11:e7:2d:77:89:39:c3:eb:d4
debug1: Host '172.17.0.4' is known and matches the ECDSA host key.
debug1: Found key in /home/voyd/.ssh/known_hosts:26
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/voyd/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: Authentication succeeded (publickey).
Authenticated to 172.17.0.4 ([172.17.0.4]:22).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env COLORTERM = xfce4-terminal
debug1: Sending env TERM = screen-256color
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending env LC_COLLATE = C
debug1: Sending env LC_NUMERIC = de_DE.UTF-8
debug1: Sending env LC_TIME = de_DE.UTF-8
debug1: Sending env LC_MONETARY = de_DE.UTF-8
debug1: Sending env LC_PAPER = de_DE.UTF-8
debug1: Sending env LC_NAME = de_DE.UTF-8
debug1: Sending env LC_ADDRESS = de_DE.UTF-8
debug1: Sending env LC_TELEPHONE = de_DE.UTF-8
debug1: Sending env LC_MEASUREMENT = de_DE.UTF-8
debug1: Sending env LC_IDENTIFICATION = de_DE.UTF-8
debug1: Sending env LC_MESSAGES = en_US.UTF-8
PTY allocation request failed on channel 0
stdin: is not a tty

`my_init` crashes entire Mac OS 10.9.2 system

Running my_init on Mac OS 10.9.2 crashes the entire system, dumping it to a blank grey screen and requiring a reboot.

Warning, by the nature of this issue, running the examples may crash your system.

This first happened when I invoked my_init from Mac OS to test exit status fixes for #45:

python my_init --skip-runit -- bash -c "exit 42"

A simpler and more universal test-case:

URL="https://raw.githubusercontent.com/phusion/baseimage-docker/master/image/my_init"
curl $URL | /usr/bin/python

I get the same crash with:

  • System Python 2.7.5 at /usr/bin/python
  • Homebrew Python 2.7.6 at /usr/local/bin/python

I realize Mac OS isn't the target system for this program, but it'd be nice to be able to test e.g. exit status bugs on any python-capable system, and the crash is very strange.

remove contents of /var/lib/apt/lists/

apt-get update pulls files with over 80 MByte into the directory /var/lib/apt/lists/.
After building the image those files could be removed (in cleanup.sh):

rm -rf /var/lib/apt/lists/*

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.