How to use Docker to create C and C++ Conan packages¶
With Docker, you can run different virtual Linux operating systems in a Linux, Mac OSX or Windows machine. It is useful to reproduce build environments, for example to automate CI processes. You can have different images with different compilers or toolchains and run containers every time is needed.
In this section you will find a list of pre-built images with common build tools and compilers as well as Conan installed.
Using Conan inside a container¶
$ docker run -it --rm --name conangcc11 conanio/gcc11-ubuntu16.04 /bin/bash
sudo when needed to run
The previous code will run a shell in container. We have specified:
- -it: Keep STDIN open and allocate a pseudo-tty, in other words, we want to type in the container because we are opening a bash.
- --rm: Once the container exits, remove the container. Helps to keep clean or hard drive.
- --name conangcc11`: The Docker container name
- conanio/gcc11-ubuntu16.04: Image name, check the available Docker images.
- /bin/bash: The command to run
Now we are running on the conangcc11 container we can use Conan normally. In the following example we are creating a package from the recipe by cloning the repository, for OpenSSL. It is always recommended to upgrade Conan from pip first:
$ pip install conan --upgrade # We make sure we are running the latest Conan version $ git clone https://github.com/conan-io/conan-center-index $ cd conan-center-index/recipes/openssl/1.x.x $ conan create . 1.1.1n@
Available Docker images¶
We provide a set of images with the most common compilers installed that can be used to generate Conan packages for different profiles. Their dockerfiles can be found in the Conan Docker Tools repository.
The images listed below are intended for generating open-source library packages and we cannot guarantee any kind of stability. We strongly recommend using your own generated images for production environments taking these dockerfiles as a reference.
|conanio/gcc5-ubuntu16.04 (GCC 5)||x86_64|
|conanio/gcc6-ubuntu16.04 (GCC 6)||x86_64|
|conanio/gcc7-ubuntu16.04 (GCC 7)||x86_64|
|conanio/gcc8-ubuntu16.04 (GCC 8)||x86_64|
|conanio/gcc9-ubuntu16.04 (GCC 9)||x86_64|
|conanio/gcc10-ubuntu16.04 (GCC 10)||x86_64|
|conanio/gcc11-ubuntu16.04 (GCC 11)||x86_64|
|conanio/clang10-ubuntu16.04 (Clang 10)||x86_64|
|conanio/clang11-ubuntu16.04 (Clang 11)||x86_64|
|conanio/clang12-ubuntu16.04 (Clang 12)||x86_64|
|conanio/clang13-ubuntu16.04 (Clang 13)||x86_64|
|conanio/clang14-ubuntu16.04 (Clang 14)||x86_64|