Score:0

Docker - ubuntu 21.04 - low host CPU usage

us flag

I'm running a LAMP application using docker compose on Ubuntu 21.04. The application is extremely slow.

Checking the docker stats I'm seeing that the CPU % usage, while loading a page, is most of the time around 0.01*% except few spikes, that unfortunately lasts few seconds, where the CPU usage hits an higher percentage (around 20%- 30%).

Docker info:

WARNING: Error loading config file: .dockercfg: $HOME is not defined
Client:
Context:    default
Debug Mode: false

Server:
Containers: 13
 Running: 3
 Paused: 0
 Stopped: 10
Images: 34
Server Version: 19.03.13
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 8fba4e9a7d01810a393d5d25a3621dc101981175
runc version: 
init version: fec3683
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 5.11.0-22-generic
Operating System: Ubuntu Core 18
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 15.36GiB
Name: fabrizio-XPS-13-9305
ID: C7F4:H3BH:6S65:I24Q:PJ4W:EEBN:SXMH:V2GN:B67C:XYUL:R56O:5AKX
Docker Root Dir: /var/snap/docker/common/var-lib-docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

Here is docker-compose.yml file:

version: '3'
services:
  apache:
    depends_on:
      - mariadb
    build:
      context: .
      dockerfile: apache/Dockerfile
      args:
        URL : 'fp.example.com'
    environment:
      - URL=fp.example.com
    image: apache
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ../fp.example:/var/www/fp.example
      - ./logs/apache:/var/log/apache2
    links:
      - mariadb:database"
      - solr:solr"

  mariadb:
    image: mariadb:10.5-focal
    ports:
      - "3306:3306"
    volumes:
      - ./mysql:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: ***********
      MYSQL_DATABASE: *********
      MYSQL_USER: ***********
      MYSQL_PASSWORD: ***********
  solr:
    image: solr:8
    ports:
      - "8983:8983"
    volumes:
      - ./solr:/var/solr


Here is my apache Dockerfile:

FROM ubuntu:20.04

LABEL Description="Ubuntu Lamp [APACHE PHP MYSQL]" \
    License="Apache License 2.0" \
    Usage="" \
    Version="1.0"

ARG URL

ENV TERM=xterm\
    TZ=Europe/Berlin\
    DEBIAN_FRONTEND=noninteractive

RUN apt-get update
#RUN apt-get upgrade -y

RUN apt-get install -y --fix-missing \
    tar \
    zip \
    unzip \
    sed \
    nano \
    apache2 \
    libapache2-mod-php \
    php \
    php-cli \
    php-common \
    php-dev \
    php-fpm \
    php-gd \
    php-json \
    php-mbstring \
    php-mysql \
    php-readline \
    php-soap \
    php-tidy \
    php-xdebug \
    php-xmlrpc \
    php-zip \
    composer
# -- CHERRY -- #

RUN mkdir /var/www/$URL
RUN chown -R www-data:www-data /var/www/$URL

COPY /apache/apache.conf /etc/apache2/sites-available/
COPY /apache/php.ini /etc/php/7.4/apache2/
COPY /apache/cert/myCA.crt /usr/local/share/ca-certificates/
COPY /apache/cert/crt /etc/apache2/ssl/
COPY /apache/cert/key /etc/apache2/ssl/

# -- VOLUMES -- #
VOLUME /var/www/$URL
VOLUME /var/log/apache2


#APACHE
RUN a2enmod rewrite
RUN a2enmod ssl
RUN a2dissite 000-default
RUN a2ensite apache
RUN phpenmod xdebug
RUN phpenmod tidy
RUN update-ca-certificates

#XDEBUG
RUN echo "xdebug.remote_enable = 1" >> /etc/php/7.4/mods-available/xdebug.ini
RUN echo "xdebug.remote_host = docker.for.mac.host.internal" >> /etc/php/7.4/mods-available/xdebug.ini
RUN echo "xdebug.remote_port = 10000" >> /etc/php/7.4/mods-available/xdebug.ini
RUN echo "xdebug.remote_autostart = 1" >> /etc/php/7.4/mods-available/xdebug.ini
RUN echo "xdebug.remote_log=/var/log/apache2/xdebug.log" >> /etc/php/7.4/mods-available/xdebug.ini

EXPOSE 80
EXPOSE 443

CMD service apache2 start && tail -f /dev/null


I'm posting this here since the same project, running on mac and windows, is working nicely. So i think the problem might comes from docker on ubuntu.

Thanks all in advance.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.