How do you add items to .dockerignore?

前端 未结 8 996
醉话见心
醉话见心 2020-12-29 01:04

I\'m not able to find many examples of what a .dockerignore file should look like.

Using puppet to install a few packages on a docker container causes the image to

8条回答
  •  旧时难觅i
    2020-12-29 01:55

    http://docs.docker.com/articles/dockerfile_best-practices/

    It seems to me your approach is backwards (agreeing with @csanchez), and that you should be generating your docker container from puppet, not running puppet in the container...

    Also, you should && the install/apply/clean lines together... each docker command creates an incremental image... If there are temporary/resource files that are part of the centos yum commands, you should likewise do the same.

    FROM centos:centos6
    
    # Add your needed files first
    # maybe you could use a baseimage and make this a volume mount point?
    Add Puppetfile / 
    
    # combine multiple commands with cleanup of cache/temporary
    # space in the same run sequence to reduce wasted diff image space.
    
    #Work around selinux problem on cent images
    RUN yum install -y --enablerepo=centosplus libselinux-devel && \
        yum install -y wget git tar openssh-server; yum -y clean all && \
        librarian-puppet install && \
        puppet apply --modulepath=/modules -e "class { 'buildslave': jenkins_slave => true,}" && \
        librarian-puppet clean

    I'd REALLY suggest avoiding SELINUX in a container, it doesn't give you anything inside a container. Not to mention, that depending on what you are trying to create, there are smaller places to start from than centos6. I believe ubuntu is smaller, debian:wheezy smaller still, or even alpine for tiny start point.

    It is worth noting, that your file size, if you're using a file system that supports virtual mounts, can reuse the same base image for multiple instances, so it won't grown more

提交回复
热议问题