I build container:
docker build -t mediawiki31 .
Dockerfile with wikimedia (standard file plus adding VisualEditor):
FROM php:7.2-apache
# System Dependencies.
RUN apt-get update && apt-get install -y \
        git \
        imagemagick \
        libicu-dev \
        # Required for SyntaxHighlighting
        python3 \
    --no-install-recommends && rm -r /var/lib/apt/lists/*
# Install the PHP extensions we need
RUN docker-php-ext-install mbstring mysqli opcache intl
# Install the default object cache.
RUN pecl channel-update pecl.php.net \
    && pecl install apcu \
    && docker-php-ext-enable apcu
# set recommended PHP.ini settings
# see https://secure.php.net/manual/en/opcache.installation.php
RUN { \
        echo 'opcache.memory_consumption=128'; \
        echo 'opcache.interned_strings_buffer=8'; \
        echo 'opcache.max_accelerated_files=4000'; \
        echo 'opcache.revalidate_freq=60'; \
        echo 'opcache.fast_shutdown=1'; \
        echo 'opcache.enable_cli=1'; \
    } > /usr/local/etc/php/conf.d/opcache-recommended.ini
# SQLite Directory Setup
RUN mkdir -p /var/www/data \
    && chown -R www-data:www-data /var/www/data
# Version
ENV MEDIAWIKI_MAJOR_VERSION 1.31
ENV MEDIAWIKI_BRANCH REL1_31
ENV MEDIAWIKI_VERSION 1.31.1
ENV MEDIAWIKI_SHA512 ee49649cc37d0a7d45a7c6d90c822c2a595df290be2b5bf085affbec3318768700a458a6e5b5b7e437651400b9641424429d6d304f870c22ec63fae86ffc5152
# MediaWiki setup
RUN curl -fSL "https://releases.wikimedia.org/mediawiki/${MEDIAWIKI_MAJOR_VERSION}/mediawiki-${MEDIAWIKI_VERSION}.tar.gz" -o mediawiki.tar.gz \
    && echo "${MEDIAWIKI_SHA512} *mediawiki.tar.gz" | sha512sum -c - \
    && tar -xz --strip-components=1 -f mediawiki.tar.gz \
    && rm mediawiki.tar.gz \
    && chown -R www-data:www-data extensions skins cache images
RUN cd /var/www/html/extensions &&\
    git clone -b REL1_30 https://gerrit.wikimedia.org/r/p/mediawiki/extensions/VisualEditor.git &&\
    cd VisualEditor &&\
    git submodule update --init
docker-compose file (also standard file but width parsoid):
# MediaWiki with MariaDB
#
# Access via "http://localhost:8024"
#   (or "http://$(docker-machine ip):8024" if using docker-machine)
version: '3'
services:
  mediawiki:
    image: mediawiki31
    restart: always
    ports:
      - 8024:80
    links:
      - database
      - parsoid
    volumes:
      - /var/www/html/images
      # After initial setup, download LocalSettings.php to the same directory as
      # this yaml and uncomment the following line and use compose to restart
      # the mediawiki service
      - ./LocalSettings.php:/var/www/html/LocalSettings.php
  database:
    image: mariadb
    restart: always
    environment:
      # @see https://phabricator.wikimedia.org/source/mediawiki/browse/master/includes/DefaultSettings.php
      MYSQL_DATABASE: my_wiki
      MYSQL_USER: pscn
      MYSQL_PASSWORD: example
      MYSQL_RANDOM_ROOT_PASSWORD: "yes"
  parsoid:
    image: thenets/parsoid:0.9.0
    ports:
      - 8035:8000
    restart: always
    environment:
      PARSOID_DOMAIN_localhost: http://localhost:8024/api.php
I ran compose ffile with:
docker-compose -f stack.yml up
Generate LocalSettings.php.
Added to LocalSettings.php:  
wfLoadExtension( 'VisualEditor');
$wgDefaultUserOptions['usebetatoolbar'] = 1;
$wgDefaultUserOptions[`usebetatoolbar-cgd`] = 1;
$wgDefaultUserOptions['wikieditor-preview'] = 0;
$wgDefaultUserOptions['wikieditor-publish'] = 0;
#$wgDefaultUserOptions['visualeditor-enable'] = 1;
  if ( $_SERVER['REMOTE_ADDR'] == '127.0.0.1' ) {
     $wgGroupPermissions['*']['read'] = true;
     $wgGroupPermissions['*']['edit'] = true;
    }
$wgVirtualRestConfig['modules']['parsoid'] = array(
    // URL to the Parsoid instance
    // Use port 8142 if you use the Debian package
    'url' => 'localhost:8035',
    // Parsoid "domain", see below (optional)
    'domain' => 'localhost',
    // Parsoid "prefix", see below (optional)
    'prefix' => 'localhost'
);
I turned on the wiki. Everything works.
I'm trying to turn on the VisualEditor and I get errors:  
apierror-visualeditor-docserver-http-error: (curl error: 7) Couldn't connect to server. 
and
oldidnotfound: There is no revision with ID 0
I check, url http://localhost:8024/api.php has content, url http://localhost:8035/ too.
Where is the problem?
I do not even know what and how to check what causes the problem.