Docker, Cent OS, PhantomJS Font Format Issue - node.js

I am running a phantomJS command which converts HTML to a PDF buffer on Docker containing Cent OS. The PDF renders fine, but the font/font format is rendering
The available fonts on the system are:
/usr/share/fonts/lyx/eufm10.ttf: eufm10:style=LyX
/usr/share/fonts/lyx/cmsy10.ttf: cmsy10:style=LyX
/usr/share/fonts/lyx/msam10.ttf: msam10:style=LyX
/usr/share/fonts/lyx/cmmi10.ttf: cmmi10:style=LyX
/usr/share/fonts/lyx/wasy10.ttf: wasy10:style=LyX
/usr/share/fonts/lyx/esint10.ttf: esint10:style=LyX
/usr/share/fonts/lyx/rsfs10.ttf: rsfs10:style=LyX
/usr/share/fonts/lyx/stmary10.ttf: stmary10:style=LyX
/usr/share/fonts/lyx/cmex10.ttf: cmex10:style=LyX
/usr/share/fonts/lyx/msbm10.ttf: msbm10:style=LyX
/usr/share/fonts/lyx/cmr10.ttf: cmr10:style=LyX
How do I fix this to use a readable font?
I can enforce an inline style font family but what would I set it to in order for it to be readable?
Perhaps I should be installing fonts in my Docker file.
Thanks!

Forgot to follow up on this but basically found some libs to fill this void and fix the font issue. Hope it will be useful if anyone runs into this issue.. In my Dockerfile, I run the following:
RUN yum install libXext -y
RUN yum install libXrender -y
RUN yum install xorg-x11-fonts-Type1 -y
RUN yum install xorg-x11-fonts-75dpi -y
RUN yum install xorg-x11-fonts-100dpi -y

Related

Python 3.6 in tensorflow gpu docker images

How can I have python3.6 in tensorflow docker images.
All the images I tried (latest, nighty) are using python3.5 and I don't want to modify all my scripts.
The Tensorflow images are based on Ubuntu 16.04, as you can see from the Dockerfile. This release ships with Python 3.5 as standard.
So you'll have to re-build the image, and the Dockerfile will need editing, even though you need to do the actual build with the parameterized_docker_build.sh script.
This answer on ask Ubuntu covers how to get Python 3.6 on Ubuntu 16.04
The simplest way would probably be just to change the From line in the Dockerfile to FROM ubuntu:16.10, and python to python3.6 in the initial apt-get install line
Of course, this may break some other Ubuntu version-specific thing, so an alternative would be to keep Ubuntu 16.04 and install one of the alternative ppa's also listed in the linked answer:
RUN add-apt-repository ppa:deadsnakes/ppa &&
apt-get update &&
apt-get install -y python3.6
Note that you'll need this after the initial apt-get install, because that installs software-properties-common, which you need to add the ppa.
Note also, as in the comments to the linked answer, that you will need to symlink to Python 3.6.
Finally, note that I haven't tried any of this. The may be gotchas, and you may need to make another change to ensure that the correct version of Python is used by the running container.
You can use stable images which are supplied by third parties, like ufoym/deepo.
One that fits TensorFlow, python3.6 and cuda10 can be found here or you can pull it directly using the command docker pull ufoym/deepo:py36-cu100
I use their images all the time, never had problems
With this anwer, I just wanted to specify how I solved this problem (the previous answer of SiHa helped me a lot but I had to add a few steps so that it worked completly).
Context:
I'm using a package (segmentation model for unet++) that requires tensorflow==1.4.0 and keras==2.2.2.
I tried to use the docker image for tensorflow 1.4.0, however, the default version of python of this image is 3.5 which is not compatible with my package.
I managed to install python3.6 on the docker images thanks to the following files:
My Dockerfile contains the following lines:
Dockerfile:
FROM tensorflow/tensorflow:1.4.0-gpu-py3
RUN mkdir /AI_PLATFORM
WORKDIR /AI_PLATFORM
COPY ./install.sh ./install.sh
COPY ./requirements.txt ./requirements.txt
COPY ./computer_vision ./computer_vision
COPY ./config.ini ./config.ini
RUN bash install.sh
Install.sh:
#!/urs/bin/env bash
pip install --upgrade pip
apt-get update
apt-get install -y python3-pip
add-apt-repository ppa:deadsnakes/ppa &&
apt-get update &&
apt-get install python3.6 --assume-yes
apt-get install libpython3.6
python3.6 -m pip install --upgrade pip
python3.6 -m pip install -r requirements.txt
Three things are important:
use python3.6 -m pip instead of pip, else the packages are installed on python 3.5 default version of Ubuntu 16.04
use docker run python3.6 <command> to run your containers with python==3.6
in the requirements.txt file, I had to specify the following things:
h5py==2.10.0
tensorflow-gpu==1.4.1
keras==2.2.2
keras-applications==1.0.4
keras-preprocessing==1.0.2
I hope that this answer will be useful
Maybe the image I created will help you. It is based on the cuda-10.0-devel image and has tensorflow 2.0a-gpu installed.
You can use it as base image for your own implementation. The image itself doesn't do anything. I put the image on dockerhub https://cloud.docker.com/repository/docker/patientzero/tensorflow2.0a-gpu-py3.6
The github repo is located here: https://github.com/patientzero/tensorflow2.0-python3.6-Docker
Pulling it won't do much, but for completeness:
$ docker pull patientzero/tensorflow2.0-gpu-py3.6
edit: changed to general tensorflow 2.0x image.
Also as mentioned here, the official image for the beta 2.0 release now comes with python 3.6 support

Installation and usage of 'make htmldocs'

I want to convert Linux kernel rst files to html document.
Please provide clear steps to install the required packages and commands to generate rst file to html.
I have installed sphinx with below command
sudo apt-get install sphinxsearch
Facing an error when I run 'make htmldocs'
The Sphinx 'sphinx_rtd_theme' HTML theme was not found
If possible, could you please help me with right packages to install?
It looks like tricky and I have tried enough.
I just have figured it out that there is a document in the Linux kernel which explains the required information to use 'make pdfdocs':
Reference: Documentation/doc-guide/sphinx.rst
#sudo apt-get install sphinxsearch
#sudo apt-get install python-sphinx-rtd-theme
#sudo apt-get install texlive-latex-recommended
#sudo apt-get install texlive-base
#sudo apt-get install graphviz
#sudo apt-get install imagemagick
Run below commands from kernel root directory
#/usr/bin/virtualenv ~/sphinx_1.4
#. ~/sphinx_1.4/bin/activate
#pip install -r Documentation/sphinx/requirements.txt
#make htmldocs
Generated html documents are located at Documents/output

Make phantomjs (nodejs system) use local fonts instead of webfonts

I ran into the problem of rendering very large pdf files from html with phantomjs 2.1.1
The mentioned solution was to install fonts locally on ubuntu & then have phantomjs use these.
Does anybody have experience doing this?
You should install the libfreetype6, libfreetype6-dev, libfontconfig1 and libfontconfig1-dev packages:
sudo apt-get install libfreetype6 libfreetype6-dev -y
sudo apt-get install libfontconfig1 libfontconfig1-dev -y
You may also need to set the following value in your bash profile:
LC_ALL=en_US.UTF-8

Error installing Image Magick on Ubuntu 14.04

I have Ubuntu 14.04 on DigitalOcean, I tried to install ImageMagick
I have found and followed this instruction
I have updated my installation with this command
sudo apt-get update
Then I tried following
wget http://mirror.checkdomain.de/imagemagick/ImageMagick-6.9.2-10.tar.gz
tar -xvzf ImageMagick-6.9.2-10.tar.gz
cd ImageMagick-6.9.2-10
./configure
sudo make
sudo make install
But while it sudo make process, it returns error as you can see in the screen shot.
What I am doing wrong and how can I install it correctly?
First all it is a good practice to have things updated:
sudo apt-get update
Next, you should install imagemagick and php5-imagick from the repository:
sudo apt-get install imagemagick php5-imagick
And finally reload your web server.

How to run vi on docker container?

I have installed docker on my host virtual machine. And now want to create a file using vi.
But it's showing me an error:
bash: vi: command not found
login into container with the following command:
docker exec -it <container> bash
Then , run the following command .
apt-get update
apt-get install vim
The command to run depends on what base image you are using.
For Alpine, vi is installed as part of the base OS. Installing vim would be:
apk -U add vim
For Debian and Ubuntu:
apt-get update && apt-get install -y vim
For CentOS, vi is usually installed with the base OS. For vim:
yum install -y vim
This should only be done in early development. Once you get a working container, the changes to files should be made to your image or configs stored outside of your container. Update your Dockerfile and other files it uses to build a new image. This certainly shouldn't be done in production since changes inside the container are by design ephemeral and will be lost when the container is replaced.
USE THIS:
apt-get update && apt-get install -y vim
Explanation of the above command
apt-get update => Will update the current package
apt-get install => Will install the package
-y => Will by pass the permission, default permission will set to Yes.
vim => Name of the package you want to install.
Your container probably haven't installed it out of the box.
Run apt-get install vim in the terminal and you should be ready to go.
Add the following line in your Dockerfile then rebuild the docker image.
RUN apt-get update && apt-get install -y vim
Alternatively, keep your docker images small by not installing unnecessary editors. You can edit the files over ssh from the docker host to the container:
vim scp://remoteuser#container-ip//path/to/document
error:: bash: vi: command not found
run the below command by logging as root user to the container--
docker exec --user="root" -it (container ID) /bin/bash
apt-get update
apt-get install vim
Use below command in Debian based container:
apt-get install vim-tiny
Complete instruction for using in Dockerfile:
RUN apt-get update && apt-get install --no-install-recommends -y \
vim-tiny \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
It doesn't install unnecessary packages and removes unnecessary downloaded files, so your docker image size won't increase dramatically.
The most voted answer has the correct idea, however, it did not work in my case. The comment from #java25 did the trick in my case. I had to log into the docker container as a root user to install vim. I am just posting the comment as an answer so that it is easier for others, having the similar problem, to find it.
docker exec -ti --user root <container-id> /bin/bash
Once you are inside docker, run the following commands now to install vi.
apt-get update
apt-get install vim
To install within your Docker container you can run command
docker exec apt-get update && apt-get install -y vim
But this will be limited to the container in which vim is installed.
To make it available to all the containers, edit the Dockerfile and add
RUN apt-get update && apt-get install -y vim
or you can also extend the image in the new Dockerfile and add above command. Eg.
FROM < image name >
RUN apt-get update && apt-get install -y vim
Inside container (in docker, not in VM), by default these are not installed.
Even apt-get, wget will not work. My VM is running on Ubuntu 17.10. For me yum package manager worked.
Yum is not part of Debian or ubuntu. It is part of red-hat. But, it works in Ubuntu and it is installed by default like apt-get
To install vim, use this command
yum install -y vim-enhanced
To uninstall vim :
yum uninstall -y vim-enhanced
Similarly,
yum install -y wget
yum install -y sudo
-y is for assuming yes if prompted for any question asked after doing yum install package-name
error:: bash: vim: command not found
Run the below command by logging as root user to the container:
microdnf install -y vim
If you actually want a small editor for simple housekeeping in a docker, use this in your Dockerfile:
RUN apt-get install -y busybox && ln -s /bin/busybox /bin/vi
I used it on an Ubuntu 18 based docker.
(Of course you might need an RUN apt-get update before it but if you are making your own Docker file you probably already have that.)
Usually changing a file in a docker container is not a good idea. Everyone will forget about the change after a while. A good way is to make another docker image from the original one.
Say in a docker image, you need to change a file named myFile.xml under /path/to/docker/image/. So, you need to do.
Copy myFile.xml in your local filesystem and make necessary changes.
Create a file named 'Dockerfile' with the following content-
FROM docker-repo:tag
ADD myFile.xml /path/to/docker/image/
Then build your own docker image with docker build -t docker-repo:v-x.x.x .
Then use your newly build docker image.

Resources