Thursday, October 4, 2018


Working with Alfresco 6.0 in Docker Containers


For the purpose of this knowledge base article, Alfresco 6.0 as part of a docker container was installed on Ubuntu 18.04. Below are links to instructions on how to install Docker and Docker-Componse. Should you need to install Docker and Docker-Compose for other operating systems, Docker's install section provides instructions for those as well. After docker and docker-compose are installed, you should be able to follow the rest with your own workstation no matter the OS.

Install Docker

https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-18-04

Install Docker-Compose

https://www.digitalocean.com/community/tutorials/how-to-install-docker-compose-on-ubuntu-18-04

To download the needed docker-compose.yml file, you can request a 30-day trial here:

https://www.alfresco.com/platform/content-services-ecm/trial/download

Once you get the docker-compose.yml file, you can create a directory and place the file there.

First, make sure that the docker service is running:

# sudo service docker start

You then start up the containerized Alfresco using this command run in the same directory that contains docker-compose.yml:

$ sudo docker-compose up
Creating network "docker-compose_default" with the default driver
Creating docker-compose_libreoffice_1           ... done
Creating docker-compose_solr6_1                 ... done
Creating docker-compose_tika_1                  ... done
Creating docker-compose_alfresco-pdf-renderer_1 ... done
Creating docker-compose_postgres_1              ... done
Creating docker-compose_shared-file-store_1     ... done
Creating docker-compose_share_1                 ... done
Creating docker-compose_activemq_1              ... done
Creating docker-compose_alfresco_1              ... done
Creating docker-compose_imagemagick_1           ... done
Attaching to docker-compose_tika_1, docker-compose_postgres_1, docker-compose_alfresco-pdf-renderer_1, docker-compose_shared-file-store_1, docker-compose_solr6_1, docker-compose_share_1, docker-compose_libreoffice_1, docker-compose_imagemagick_1, docker-compose_alfresco_1, docker-compose_activemq_1

You will see Alfresco (and the other components) go through its startup messages.

Once you see a message similar to this in the logs:

alfresco_1 | 03-Oct-2018 21:28:47.888 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 232188 ms

You can then go to the UI in your browser:

http://localhost:8080/share

And log in with "admin" as the username and "admin" as the password.

If you ever need to have a deeper look into the Alfresco system itself as it's running in the containers, you can still directly access things like the Alfresco database or the filesystem where Alfresco resides.

To access the database, you can install a Postgresql client like PGAdmin3 and use the following connection endpoints:

Hostname: localhost
Port: 5432
Database: alfresco
Username: alfresco
Password: admin

To access the filesystem, you can use these commands to log into the container's shells (you should see something similar to the following):

$ docker ps 
CONTAINER ID        IMAGE                                            COMMAND                  CREATED             STATUS              PORTS                                                                                                                     NAMES
5528be5a1e5a        alfresco/alfresco-content-repository:6.1.0-EA1   "catalina.sh run -se…"   6 minutes ago       Up 6 minutes        0.0.0.0:8082->8080/tcp                                                                                                    docker-compose_alfresco_1
1716ad9c4e82        alfresco/alfresco-share:6.0                      "/usr/local/tomcat/s…"   6 minutes ago       Up 6 minutes        0.0.0.0:8080->8080/tcp                                                                                                    docker-compose_share_1
d6485df206f8        alfresco/alfresco-shared-file-store:0.1          "/bin/sh -c 'java -j…"   6 minutes ago       Up 6 minutes        0.0.0.0:8099->8099/tcp                                                                                                    docker-compose_shared-file-store_1
588003fbf981        webcenter/activemq:5.14.3                        "/app/run.sh"            6 minutes ago       Up 6 minutes        0.0.0.0:5672->5672/tcp, 0.0.0.0:8161->8161/tcp, 1883/tcp, 0.0.0.0:61613->61613/tcp, 61614/tcp, 0.0.0.0:61616->61616/tcp   docker-compose_activemq_1
58443c670b7c        alfresco/alfresco-pdf-renderer:1.3               "/bin/sh -c 'java $J…"   6 minutes ago       Up 6 minutes        0.0.0.0:8090->8090/tcp                                                                                                    docker-compose_alfresco-pdf-renderer_1
99582bc076ed        alfresco/alfresco-search-services:1.1.1          "/opt/alfresco-searc…"   6 minutes ago       Up 6 minutes        0.0.0.0:8083->8983/tcp                                                                                                    docker-compose_solr6_1
8bb3bb72d73c        postgres:10.1                                    "docker-entrypoint.s…"   6 minutes ago       Up 6 minutes        0.0.0.0:5432->5432/tcp                                                                                                    docker-compose_postgres_1
ec543faec7e8        alfresco/alfresco-libreoffice:1.3                "/bin/sh -c 'java $J…"   6 minutes ago       Up 6 minutes        0.0.0.0:8092->8090/tcp                                                                                                    docker-compose_libreoffice_1
e8073fe6a48f        alfresco/alfresco-tika:1.3                       "/bin/sh -c 'java -j…"   6 minutes ago       Up 6 minutes        0.0.0.0:8093->8090/tcp                                                                                                    docker-compose_tika_1
9d2bb4a7c605        alfresco/alfresco-imagemagick:1.3                "/bin/sh -c 'java $J…"   6 minutes ago       Up 6 minutes        0.0.0.0:8091->8090/tcp                                                                                                    docker-compose_imagemagick_1


Looking at the list we can see that the container id for the running Alfresco image is "5528be5a1e5a".

We can then use the docker interactive command to get access to the filesystem:

$ sudo docker exec -it 5528be5a1e5a /bin/bash

And now we have an interactive session. Below you can see that the login directory is in /usr/local/tomcat. As root however, you should be able to change to any other directory in this container if needed.

[root@5528be5a1e5a tomcat]# pwd

/usr/local/tomcat

If you ever need to make an edit to the running container's Alfresco settings (in alfresco-global.properties for example), you can do the following:

# vi shared/classes/alfresco-global.properties 

Just keep in mind that whatever changes you make will not persist should you turn off the container. To persist any changes to the system that will survive a restart, you'll need to come out of this interactive shell and run a docker commit command to save its state. To test this, you can do the following:

# touch test 

This will create an empty file called test in /usr/local/tomcat.

Next, commit the change by issuing the following command outside the container and on your local workstation:

# docker commit 5528be5a1e5a alfresco/alfresco-content-repository:6.1.0-EA1 

The format is:

# docker commit [container id] [image id]

After this, go ahead and run the local stop command to stop Alfresco.

$ sudo docker-compose down
Stopping docker-compose_alfresco_1              ... done
Stopping docker-compose_share_1                 ... done
Stopping docker-compose_shared-file-store_1     ... done
Stopping docker-compose_activemq_1              ... done
Stopping docker-compose_alfresco-pdf-renderer_1 ... done
Stopping docker-compose_solr6_1                 ... done
Stopping docker-compose_postgres_1              ... done
Stopping docker-compose_libreoffice_1           ... done
Stopping docker-compose_tika_1                  ... done
Stopping docker-compose_imagemagick_1           ... done
Removing docker-compose_alfresco_1              ... done
Removing docker-compose_share_1                 ... done
Removing docker-compose_shared-file-store_1     ... done
Removing docker-compose_activemq_1              ... done
Removing docker-compose_alfresco-pdf-renderer_1 ... done
Removing docker-compose_solr6_1                 ... done
Removing docker-compose_postgres_1              ... done
Removing docker-compose_libreoffice_1           ... done
Removing docker-compose_tika_1                  ... done
Removing docker-compose_imagemagick_1           ... done
Removing network docker-compose_default

Now, to see if our change persisted, go ahead and start the Alfresco containers:

$ sudo docker-compose up
Creating network "docker-compose_default" with the default driver
Creating docker-compose_tika_1                  ... done
Creating docker-compose_imagemagick_1           ... done
Creating docker-compose_libreoffice_1           ... done
Creating docker-compose_alfresco-pdf-renderer_1 ... done
Creating docker-compose_solr6_1                 ... done
Creating docker-compose_postgres_1              ... done
Creating docker-compose_activemq_1              ... done
Creating docker-compose_share_1                 ... done
Creating docker-compose_shared-file-store_1     ... done
Creating docker-compose_alfresco_1              ... done

...

Get the container id:

$ docker ps
CONTAINER ID        IMAGE                                            COMMAND                  CREATED             STATUS              PORTS                                                                                                                     NAMES
8275de822b40        alfresco/alfresco-content-repository:6.1.0-EA1   "catalina.sh run -se…"   3 minutes ago       Up 3 minutes        0.0.0.0:8082->8080/tcp                                                                                                    docker-compose_alfresco_1

Attach to the running container:

$ sudo docker exec -it 8275de822b40 /bin/bash

And if you run an "ls", you should see that your "test" file has persisted. Keep in mind that you can do the same with the database image if you don't want to have Alfresco reinstall its repository on every startup. Also, when you make commits, by default, older images are kept. So, if you need to, you can revert your current set of images back to the original ones.

No comments:

Post a Comment