LoginSignup
5
6

More than 5 years have passed since last update.

DockerのPythonイメージで暗号化ライブラリcryptographyを利用する

Posted at

暗号化ライブラリパッケージcryptographyをDocker Pythonイメージから使う方法について。2016年5月26日現在。

pyca/cryptographyとは

pip install cryptography

Dockerfile
FROM python:3-slim

RUN pip install cryptography

2016年5月26日現在、依存モジュールcffiがwheel提供されていないため、これではうまくいきません。

DOs

Debianベースの場合。

Dockerfile
FROM python:3-slim

RUN apt install python-cffi && pip install cryptography

jessieだと、cffi 1.4.2が入ります。

また、自明ですが、Alpineベース(e.g., python:3-alpine)はこれではうまくいきません。

DON'Ts

Dockerfile
RUN apt-get update && apt-get install -y build-essential libssl-dev libffi-dev python-dev

理由

イメージサイズが大きくなるため。ただし、最新のcffi(2016年5月26日現在 cffi 1.6.0)が使えるメリットはあります。

まとめ

それでは快適な暗号化プログラミングライフを。

5
6
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6