ICode9

精准搜索请尝试: 精确搜索
首页 > 编程语言> 文章详细

Docker packaging guide for Python

2020-01-30 12:02:13  阅读:331  来源: 互联网

标签:builds Python packaging how build Docker your


以下是一些关于python 集成docker 的文章,很不错

The basics

  1. Broken by default: why you should avoid most Dockerfile examples
    Most Dockerfile examples you’ll find on the Web are broken. And that’s a problem.
  2. A review of the official Dockerfile best practices: good, bad, and insecure
    The official Docker documentation’s Dockerfile best practices are mostly good—but they omit some important information.
  3. The best Docker base image for your Python application (January 2020)
    Ubuntu? Official Python images? Alpine Linux? Here’s how to choose a good base image.
  4. Alpine makes Python Docker builds 50× slower, and images 2× larger
    Alpine Linux is often recommended as a smaller, faster base image. But if you’re using Python, it will actually do the opposite.
  5. When to switch to Python 3.8
    Python 3.8 is out now—when should you start using it?
  6. Connection refused? Docker networking and how it impacts your image
    A command that runs fine on your computer may fail with connection refused when run in a container. You’ll learn why that happens, and how to prevent it.
  7. Faster or slower: the basics of Docker build caching
    Docker’s layer caching can speed up your image build—if you write your Dockerfile correctly.
  8. Installing system packages in Docker with minimal bloat
    Your Docker build needs to update system packages for security, and perhaps to install them for additional dependnecies. Here’s how to do it without making your image too large, on Debian, Ubuntu, CentOS and RHEL.

Security

  1. Avoiding insecure images from Docker build caching
    Docker’s layer caching is great for speeding up builds—but you need to be careful or it’ll cause you to have insecure dependencies.
  2. Less capabilities, more security: minimizing privilege escalation in Docker
    To reduce the security risk from your Docker image, you should run it as a non-root user. You should also reduce it capabilities: learn what, why, and how.
  3. Docker build secrets, the sneaky way
    When you’re building Docker images you often need some secrets: a password, an SSH key. For now, Docker lacks a good mechanism to pass in secrets in a secure way, which means you need to get sneaky.

Fast builds, small images

  1. The high cost of slow Docker builds
    A slow Docker build on the critical path for developer feedback is a lot more expensive than you think.
  2. Faster Docker builds with pipenv, poetry, or pip-tools
    Installing dependencies separately from your code allows you to take advantage of Docker’s layer caching. Here’s how to do it with pipenv, poetry, or pip-tools.
  3. Elegantly activating a virtualenv in a Dockerfile
    How to activate a virtualenv in a Dockerfile without repeating yourself—plus, you’ll learn what activating a virtualenv actually does.
  4. Multi-stage builds #1: Smaller images for compiled code
    You’re building a Docker image for a Python project with compiled code (C/C++/Rust/whatever), and somehow without quite realizing it you’ve created a Docker image that is 917MB… only 1MB of which is your code!
  5. Multi-stage builds #2: Python specifics—virtualenv, –user, and other methods
    Now that you understand multi-stage builds, here’s how to implement them for Python applications.
  6. Multi-stage builds #3: Why your build is surprisingly slow, and how to speed it up
    Multi-stage builds give you small images and fast builds—in theory. In practice, they require some tricks if you want your builds to actually be fast.

Applications and runtime

  1. Configuring Gunicorn for Docker
    Running in a container isn’t the same as running on a virtual machine or physical server: you need to configure Gunicorn (and other servers) appropriately.
  2. Activating a Conda environment in your Dockerfile
    Learn how to activate a conda environment in your Dockerfile.
  3. Decoupling database migrations from server startup: why and how
    It’s tempting to migrate your database schema when your application container starts up—here’s some reasons to rethink that choice.
  4. What’s running in production? Making your Docker images identifiable
    It’s difficult to debug production problems if you don’t know what image is running in production.
  5. A Python prompt into a running process: debugging with Manhole
    Your Python process is acting strange—wouldn’t it be useful to get a live Python interpreter prompt inside your running process?

Packaging as a process

  1. A thousand little details: developing software for ops
    Some thoughts on how to build software for ops, a domain that suffers from historical complexity and problem space complexity. And in particular, buildng a better way to do Docker packaging.
  2. Your Docker build needs a smoke test
    If you don’t test your Docker image before you push it, you’ll waste time (and maybe break production).

Products and Services

Production-ready template: best practices, faster

Instead of synthesizing every article above, spending days debugging your build process, and fighting slow builds, you can ship your Docker images with confidence—in just hours!—by using the Production-Ready Python Containers template.

标签:builds,Python,packaging,how,build,Docker,your
来源: https://www.cnblogs.com/rongfengliang/p/12242412.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有