8i | 9i | 10g | 11g | 12c | 13c | 18c | 19c | 21c | 23c | Misc | PL/SQL | SQL | RAC | WebLogic | Linux

Home » Articles » Linux » Here

Docker : Quick Tips

This article lists some quick tips that will help when learning Docker.

Related articles.

Start Containers Automatically (--restart)

The Docker documentation describes the --restart parameter of the docker run command, as well as manually controlling startup using Linux services.

The allowable values include no, on-failure, unless-stopped and always, with the default being no and possibly the most sensible option for normal use being the unless-stopped value.

$ docker run -dit --name ol7_ords_con \
             --restart unless-stopped \
             -p 8080:8080 -p 8443:8443 \
             -e "DB_HOSTNAME=my-server.localdomain" \

Clean Up Storage

This subject is discussed here.

Reduce Image Size (--squash)

If you are concerned about reducing storage usage, you should consider the --squash experimental feature described here. You can see how to enable experimental features in Oracle Linux here.

$ docker build --squash -t ol7_ords:latest .

Copy Files/Directories

The docker cp command allows you to copy files or directories into or out of a container. To copy to a volume, the volume must be mounted in a container. In the examples below the container name is "ol7_ords_con".

$ docker cp /tmp/jdk-8u151-linux-x64.tar.gz ol7_ords_con:/u01/software/jdk-8u151-linux-x64.tar.gz

$ docker cp ol7_ords_con:/u01/software/jdk-8u151-linux-x64.tar.gz /tmp/jdk-8u151-linux-x64.tar.gz

Shared Memory

You can control the amount of shared memory available to the container by using the --shm-size="" runtime constraint of the run command. Without this set the default value is 64M. You will probably need to set this hight when running an Oracle database in a container.

docker run -dit --name ol7_122_con -p 1521:1521 -p 5500:5500 --shm-size="1G" ol7_122:latest

Limiting Container Resources

Docker containers have no limits on resource usage by default., but Docker can limit container resources with many run parameters, for example.

In addition the Oracle database can internally limit resources.

So there is no need for noisy neighbours!

Kernel Parameters

Since all containers share the host kernel, the kernel parameters of the host machine should be set to appropriate values for all the containers running on it. If you are running Oracle databases in a container, you can set these by installing the preinstallation package on the host machine.

# yum -y install oracle-database-server-12cR2-preinstall

Docker Logs

The docker logs command displays log information for a specified container. It can be useful for tracking the progress of the start script for long running tasks.

$ # Like a tail -f.
$ docker logs --follow ol7_122_con

$ # Display the last 10 entries.
$ docker logs --tail 10 ol7_122_con

$ # Display all the log entries.
$ docker logs --tail ol7_122_con

Run Command in Container

You can run a command in a container using the EXEC command.

docker exec {container-name} ls /tmp

Run it as a specific user with the --user parameter.

docker exec --user root {container-name} ls /tmp

Connect to Container

You can connect to a bash shell in a container using the EXEC command.

docker exec -it {container-name} bash

Connect to a specific user with the --user parameter.

docker exec -it --user root {container-name} bash

For more information see:

Hope this helps. Regards Tim...

Back to the Top.