Create Docker image from existing Ubuntu + App - apache

I installed Moodle (eLearning PHP based app, but it could be any app) locally on Ubuntu and would like to package it as Docker image/container. There were whole bunch of installations and configurations done. I'd like to package all that so that I can deploy to some Docker enabled hosting service, such as Digital Ocean or AWS.
How do I create Docker image?
Do I need to handle networking, ports and Apache configuration for production deployment?

There ara a lot of Moodle images in dockerhub. just use one of them

The process to create docker images is well documented on Docker's documentation site. See: Build your own images
The idea is simple: You inherit/extend an existing image and make additions to it. This is done in a provisioning file called Dockerfile
Dockerfile Example:
FROM debian:8.4
MAINTAINER John Doe (j.doe#example.com)
# update aptitude
RUN apt-get clean && apt-get update
# utilities
RUN apt-get -y install vim git php5.6 apache2
In the example above I extend a Debian image, update aptitude and install a series of packages.
A full list of commands available in Dockerfiles is available at https://docs.docker.com/engine/reference/builder/
Once your Dockerfile is ready you can build the image using the following command:
docker build -t debian/enhanced:8.4 /path/to/Dockerfile

Related

Problema: conflicting requests when installing odoo in Fedora 32

I'm trying to install odoo 11 in fedora 32 but I get these errors:
Problema: conflicting requests
nothing provides pychart needed by odoo-11.0.post20191021-1.noarch
nothing provides pyparsing needed by odoo-11.0.post20191021-1.noarch
nothing provides libxslt-python needed by odoo-11.0.post20191021-1.noarch
The steps I've followed are:
Install postgresql & intiate the service
$ sudo yum localinstall https://nightly.odoo.com/11.0/nightly/rpm/odoo_11.0.20191021.noarch.rpm
It seems there are python dependencies that can't be installed but I don't know how can I install them.
Do you have any idea how can I fix this problem? Many thanks!
If the installation packages is not working for you, you can always run Odoo server from the source.
Create a virtual environment for your Odoo app, let's call it venv11.
Get Odoo source code:
git clone https://github.com/odoo/odoo.git --depth 1 -b 11.0
Activate virtual environment. Install Python3 packages using pip.
pip install -r odoo/requirements.txt
Make sure you have installed the dev libraries needed for some of the pip packages that needs to be compiled, you will face xxxx.h not found error, you have search for that library and install using your distro package manager.
After your pip package installation is complete you can generate config file for your Odoo server using following command
python odoo/odoo-bin -c odoo.conf --save --stop-after-init
Edit the config file to add some important configuration, for example, db_user, db_password, http_port.
Now that you have added DB connection details, your Odoo application can now connect with your Postgresql Database and you can start using Odoo application by creating new database. If you don't have Postgresql information, you can just switch to postgres user and create new user with super user access.
sudo su - postgres
psql
create user `username` with superuser;
alter user `username` with encrypted password 'password';
and add those information to the config file. Now you can run Odoo server using
python odoo/odoo-bin -c odoo.conf
Head back to browser, browse 127.0.0.1:8069 8069 is the default port but you can change it from the config file. The database creation web interface will appear and you can start using Odoo application.
** Note: run python commands in virtual environment activated as that will isolate pip packages.

How to Install apache httpd from source for jboss clustering

I am currently setting up a JBoss EAP 7 cluster in domain mode and the goal is for an apache webserver to be installed as a load balancer. However, I am unable to install the httpd service from yum repositories as this is a VM that was provisioned by a client. I need to install httpd from its source which I have downloaded. My problem is that I am not sure about the configuration options to enable for this purpose. Any help would be appreciated. From the official website, the instruction doesn't give details about what modules to be enabled and I'm not sure which of them are relevant for my own purpose.
Download Download the latest release from http://httpd.apache.org/download.cgi
Extract $ gzip -d httpd-NN.tar.gz
$ tar xvf httpd-NN.tar
$ cd httpd-NN
Configure $ ./configure --prefix=PREFIX
Compile $ make
Install $ make install
Customize $ vi PREFIX/conf/httpd.conf
Test $ PREFIX/bin/apachectl -k start
Above provided link will contain all module which provided with default Apache httpd. You can download the Apache httpd source folder and check module information in modules.In Apache source module/proxy folder contains module information regarding the proxy configuration. i.e mod_proxy module.
I was able to do my installation by following the guide here

start redis-server on debian/ubuntu boot

I am trying to create a docker container where redis starts at boot.
there will be other foreground services running on that other container which will connect to the redis db.
for some reason the service does not start when i run the container.
here my simplified Dockerfile
FROM debian
# this solves an issue described here:
# http://askubuntu.com/questions/365911/why-the-services-do-not-start-at-installation
RUN sed -i -e s/101/0/g /usr/sbin/policy-rc.d
# install redis-server
RUN apt-get update && apt-get install -y redis-server
# updates init script (redundant)
RUN update-rc.d redis-server defaults
# ping google to keep the container running in foreground
CMD ["ping", "google.com"]
can anybody explain me why this is not working and how this should be done right?
So a docker container is like a full OS but has some key differences. It's not going to run a full init system. It's designed and intended to run a single process tree. While you can run a supervisor such as runit et al within a container, you are really working against the grain of docker and all the tooling and documentation is going to lead you away from using containers like VMs and toward the harmony of 1 process/service per container.
So redis isn't starting because the ping command is literally the only process running in your container.
there will be other foreground services running on that other container which will connect to the redis db.
Don't do it this way. Really. Everything will be easier when you put 1 process in each container and connect them via network links.
Digging up an old question here, but I landed on it whilst trying to package a really simple Redis job queue into an existing docker image setup. I needed it to start up on image boot so the app could have access to it. Memory and performance are not a concern in this scenario or an external Redis server would absolutely be the right choice.
Here's what I did in my Dockerfile for a simple NodeJs app to make it work without editing any system files post-install:
RUN apt-get update && apt-get -y redis-server
CMD service redis-server start & node dist/src/main
Sort of crude using parallel command processes, but as the accepted answer points out this is not a real operating system so we really only care about Redis being online when the app is.

Is migration from docker to vm possible?

How to migrate from docker container to virtual machine ? Can somebody give links if any ?
vagrant up
sudo apt-get install lxc-docker
docker import ...
I'm being serious here. This is the whole fun of Docker!
If you mean migrating the services running in docker container to a VM, you could use the Dockerfile as an installation script base.

setting up tomcat in Ubuntu

I have gone through many tutorials for installing tomcat in my Ubuntu system. I installed tomcat7. tomcat7-admin, tomcat7-examples and tomcat7-docs by following commands:
apt-get install tomcat7
apt-get install tomcat7-admin
apt-get install tomcat7-docs
apt-get install tomcat7-examples
After this setup I can start, stop the server by:
/etc/init.d/tomcat7 start/stop
I have following files and folders:
/usr/share/tomcat7/
/etc/tomcat7/
/var/lib/tomcat7/
I have added the following user in tomcat-users.xml file under /usr/sharetomcat7/conf/tomcat-users.xml and /etc/tomcat7/tomcat-users.xml
<user username="admin" password="amdin" roles="admin-gui,standard,manager-gui"/>
Now when I open localhost:8080, I get a dull page saying 'It works' unlike the colorful page we get generally. These are the contents of page:
You might consider installing the following packages, if you haven't already done so:
tomcat7-docs: This package installs a web application that allows to browse the Tomcat 7 documentation locally. Once installed, you can access it by clicking here.
tomcat7-examples: This package installs a web application that allows to access the Tomcat 7 Servlet and JSP examples. Once installed, you can access it by clicking here.
tomcat7-admin: This package installs two web applications that can help managing this Tomcat instance. Once installed, you can access the manager webapp and the host-manager webapp.
But when I click on 'click here' link above to open admin, docs or examples I get "HTTP status 404: The requested resource is not available."
But I have installed admin, examples and docs. I am not getting it. Please help! I am using Ubuntu 13.04
on ubuntu 14.04 it worked for me using following command :
sudo apt-get install tomcat7-docs tomcat7-admin tomcat7-examples
Create a link for each application in webapps folder as below:
cd /var/lib/tomcat7/webapps
sudo ln -s /usr/share/tomcat7-examples/examples examples
sudo ln -s /usr/share/tomcat7-docs/docs docs
sudo ln -s /usr/share/tomcat7-admin/manager manager
sudo ln -s /usr/share/tomcat7-admin/host-manager host-manager