Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apt issues #1

Open
draeath opened this issue Dec 1, 2017 · 2 comments
Open

apt issues #1

draeath opened this issue Dec 1, 2017 · 2 comments

Comments

@draeath
Copy link

draeath commented Dec 1, 2017

Reference these lines

As each RUN statement causes a new image layer (which can be cached), when using yum/apt commands one should chain the commands in the same RUN statement. Otherwise, there is a chance of cache consistency issues. Eg:

  1. docker creates the 'RUN apt-cache' layer
  2. the repository changes
  3. docker proceeds with subsequent apt installs (there may or may not have been a significant amount of time between the initial layer and now).
  4. apt tries to utilize invalid metadata

TL;DR these lines should be adjusted to read like this, or similar:

RUN DEBIAN_FRONTEND=noninteractive apt-get update -q &&\
    DEBIAN_FRONTEND=noninteractive apt-get install -y python-pip python-apt

This will cause the apt work to be 'atomic.' You are correct in specifying DEBIAN_FRONTEND within the RUN instead of as an ENV as well, as the ENV would cause it's propagation to container runtime.

Another issue - apt can and will leave items behind in it's cache, bloating the generated images unless care is taken to clean them.

Options:

  1. 'apt-get clean' after apt operations (must chain them as I discuss earlier)
  2. manually clean up the cache
  3. (best choice) configure apt not to cache at all. a working example of this configuration can be seen here.

FINAL NOTE: you might consider using one of the buildpack-deps dockerhub images instead of using the base ubuntu image, because it will ship some of the common build dependencies "out of the box" making for a quicker build. This may result in a larger image however, as not all of these dependencies may actually be required.

@draeath
Copy link
Author

draeath commented Dec 4, 2017

Looks like this is done for Debian and something similar for Ubuntu, so the apt clean part isn't necessary.

@draeath
Copy link
Author

draeath commented Dec 4, 2017

Looks like you can also perform this command to reconfigure debconf to use the noninteractive frontend by default: echo "set debconf/frontend noninteractive" | DEBIAN_FRONTEND=noninteractive debconf-communicate (the variable is defined here as otherwise, debconf spams the error while you turn it off)

It may be desirable to set it back at the end of the build, so interactive calls get a frontend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant