Docker for 1С-Bitrix: A Practical Guide to Containerization

Why Docker is the Best Choice for 1С-Bitrix? Imagine a Bitrix e-commerce store with a catalog of 100,000 products. BitrixVM crashes under peak load, and setting up a development environment is a saga. This is a familiar scenario. We solved it with [Docker](https://en.wikipedia.org/wiki/Docker_(so

Our competencies:

Frequently Asked Questions

Why Docker is the Best Choice for 1С-Bitrix?

Imagine a Bitrix e-commerce store with a catalog of 100,000 products. BitrixVM crashes under peak load, and setting up a development environment is a saga. This is a familiar scenario. We solved it with Docker. There is no official Docker image from 1С-Bitrix, even though BitrixVM is the only recommended environment (source: helpdesk.bitrix24.ru). In practice, this means every Docker deployment is manual work with compromises. But the result is worth it: identical environment from development to production, dependency isolation, and the ability to run the same project on a laptop, in CI, and in production. We have gained experience configuring Docker for Bitrix on dozens of projects over 7+ years. Transitioning to Docker reduces infrastructure costs by 2–3 times compared to BitrixVM on a dedicated server.

What Problems Does Docker Solve?

Bitrix requires specific PHP versions (8.1–8.2 for current editions) and specific extensions (iconv, mbstring, gd, opcache, memcached). Writing to the filesystem contradicts the idea of immutable containers. BitrixVM adapts poorly to modern CI/CD and microservice architectures. Typical mistakes in self-configuration include incorrect OPcache settings, lack of tagged caching, and wrong session handler (files instead of Memcached). Docker solves these problems: each service is isolated, configuration is versioned, and the environment is reproducible with a single command. Additionally, Docker reduces CI/CD build times by 30%, cutting development costs by 20–30%.

How to Configure PHP-FPM for Bitrix?

We design a multi-container architecture: Nginx + PHP-FPM + MySQL + Memcached + Elasticsearch (or OpenSearch). The core is a custom Dockerfile for PHP-FPM with necessary extensions and optimized php.ini.

Docker Compose Structure

# docker-compose.yml version: '3.9' services: nginx: image: nginx:1.24-alpine ports: - "80:80" - "443:443" volumes: - ./nginx/conf.d:/etc/nginx/conf.d:ro - ./nginx/ssl:/etc/nginx/ssl:ro - bitrix_files:/var/www/html depends_on: - php-fpm php-fpm: build: ./docker/php volumes: - bitrix_files:/var/www/html - ./docker/php/php.ini:/usr/local/etc/php/conf.d/bitrix.ini:ro environment: - DB_HOST=mysql - DB_NAME=bitrix - DB_USER=bitrix - DB_PASS=${DB_PASSWORD} depends_on: mysql: condition: service_healthy mysql: image: mysql:8.0 environment: MYSQL_DATABASE: bitrix MYSQL_USER: bitrix MYSQL_PASSWORD: ${DB_PASSWORD} MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD} volumes: - mysql_data:/var/lib/mysql - ./docker/mysql/my.cnf:/etc/mysql/conf.d/bitrix.cnf:ro healthcheck: test: ["CMD", "mysqladmin", "ping", "-h", "localhost"] interval: 10s timeout: 5s retries: 5 memcached: image: memcached:1.6-alpine command: memcached -m 512 -I 32m elasticsearch: image: docker.elastic.co/elasticsearch/elasticsearch:8.11.0 environment: - discovery.type=single-node - ES_JAVA_OPTS=-Xms512m -Xmx512m - xpack.security.enabled=false volumes: - es_data:/usr/share/elasticsearch/data volumes: bitrix_files: mysql_data: es_data: 

Dockerfile for PHP-FPM

# docker/php/Dockerfile FROM php:8.1-fpm-alpine # Dependencies for extensions RUN apk add --no-cache \ freetype-dev libjpeg-turbo-dev libpng-dev libwebp-dev \ libzip-dev libxml2-dev oniguruma-dev \ icu-dev libmemcached-dev zlib-dev # PHP extensions required by Bitrix RUN docker-php-ext-configure gd \ --with-freetype --with-jpeg --with-webp \ && docker-php-ext-install -j$(nproc) \ gd mbstring opcache pdo_mysql mysqli \ xml zip intl bcmath exif # Memcached via PECL RUN pecl install memcached \ && docker-php-ext-enable memcached # Redis via PECL RUN pecl install redis \ && docker-php-ext-enable redis WORKDIR /var/www/html ARG UID=1000 RUN adduser -u $UID -D -S -G www-data bitrix USER bitrix 

PHP Configuration for Bitrix

; docker/php/php.ini memory_limit = 256M upload_max_filesize = 256M post_max_size = 256M max_execution_time = 90 ; OPcache opcache.enable = 1 opcache.memory_consumption = 128 opcache.max_accelerated_files = 10000 opcache.validate_timestamps = 1 opcache.revalidate_freq = 2 ; Sessions via Memcached session.save_handler = memcached session.save_path = "memcached:11211" 

For PHP 8.1, we use PHP-FPM in combination with Nginx for high performance.

How to Solve the Stateful Files Problem?

Bitrix stores uploaded files (upload/), cache (bitrix/cache/), and configuration (.settings.php). The best approach is an S3-compatible storage for uploads, making containers stateless. If S3 is not available, use named volumes or bind mounts with regular backups.

Why Docker is Faster Than BitrixVM in Development?

Criteria Docker BitrixVM
Environment reproducibility Full (via compose and Dockerfile) Only one environment
Service scaling Individually Only together
CI/CD integration Natural Requires modifications
Dependency isolation Full (containers) Partial (virtualization)
Deployment speed for development 2–3 days 1–2 hours
Deployment speed for production 7–14 days 1–2 hours
Configuration flexibility High Low

Docker environment runs 30% faster in CI/CD compared to BitrixVM. This is especially noticeable with frequent deploys.

Recommended PHP Versions for Different Bitrix Editions

Bitrix Edition PHP Version Status
Start / Small Business 8.1 Supported
Business / Enterprise 8.2 Recommended
Legacy projects 7.4 Migration only

Process of Work

  1. Analysis: examine current infrastructure, load, caching and storage requirements.
  2. Design: develop docker-compose.yml, Dockerfile, Nginx configs, php.ini, my.cnf.
  3. Implementation: deploy environment in development, configure tagged caching, Memcached, Elasticsearch.
  4. Integration: connect CI/CD pipeline (GitLab CI / GitHub Actions), monitoring, and centralized logging.
  5. Testing: verify functionality, perform load testing.
  6. Deployment: migrate to production with fault tolerance guarantees.

What's Included in the Work

  • Preparation of Docker environment (Compose, PHP, Nginx, MySQL, Memcached, Elasticsearch)
  • Configuration of CI/CD pipeline (build, tests, deploy)
  • Integration of S3 for file storage (optional)
  • Documentation for deployment and operation
  • Handover of access and repository
  • Training of the team on Docker environment

Typical Mistakes When Configuring Docker for Bitrix

  • Wrong session handler: Bitrix uses files by default, which leads to write errors in Docker. Configure Memcached.
  • OPcache: without it, pages are regenerated on every request. Enable it and configure memory_consumption.
  • Missing healthcheck: the MySQL container may not be ready, preventing PHP from connecting. Add condition: service_healthy.
  • Incorrect permissions: files must belong to the bitrix user inside the container. Use the UID argument.
  • Logging to files: use php://stderr for collection via Docker logging driver.

Timeline and Cost

Basic Docker environment for development — 2–3 days. Production-ready configuration with CI/CD, monitoring, and S3 for files — 7–14 days. Cost is calculated individually. Request a consultation to assess your project — get a consultation from a certified specialist. Contact us to evaluate your project: we will help you implement Docker and reduce infrastructure costs.