Oracle-xe docker container have weird behaviour - docker

I am new to docker I have been trying to install oracel-18xe in the docker
after installing Oracele-xe which seems to be working but
after running ./buildContainerImage.sh command
I got the following logs.
Removing intermediate container 3cd9a901da82
---> 3ed5c215ef81
Step 7/8 : HEALTHCHECK --interval=1m --start-period=5m CMD "$ORACLE_BASE/$CHECK_DB_FILE" >/dev/null || exit 1
---> Running in a1c6507ac3b9
Removing intermediate container a1c6507ac3b9
---> f48555c74740
Step 8/8 : CMD exec $ORACLE_BASE/$RUN_FILE
---> Running in c36aec16a658
Removing intermediate container c36aec16a658
---> a347238232be
Successfully built a347238232be
Successfully tagged oracle/database:18.4.0-xe
which seems correct, Then I run the command
sudo docker run --name myxedb -d -p 51521:1521 -p 55500:5500 -e ORACLE_PWD=<secret> -e ORACLE_CHARACTERSET=AL32UTF8 oracle/database:18.4.0-xe
that runs with out error but after running docker logs command
I found the following logs.
sed: can't read /etc/oratab: No such file or directory
/opt/oracle/runOracle.sh: line 194: /etc/init.d/oracle-xe-18c: No such file or directory
grep: /etc/oratab: No such file or directory
#####################################
########### E R R O R ###############
DATABASE SETUP WAS NOT SUCCESSFUL!
Please check output for further info!
########### E R R O R ###############
#####################################
The following output is now a tail of the alert.log:
/opt/oracle/checkDBStatus.sh: line 18: oraenv: No such file or directory
tail: cannot open '/opt/oracle/diag/rdbms/*/*/trace/alert*.log' for reading: No such file or directory
tail: no files remaining
but when I run docker ps command I have not found any container running
then after googling I found an other variation the command
sudo docker run --name myxedb2 -d -i -t -p 51521:1521 -p 55500:5500 -e ORACLE_PWD=<secret> -e ORACLE_CHARACTERSET=AL32UTF8 oracle/database:18.4.0-xe /bin/bash
after that I was able to see the results in the docker ps command.
but docker logs command is showing nothing.
I have some questions here.
first of-all why the first docker run command was not running and docker logs command showing logs which is quite normal.
secondly why the second command is showing all good but docker logs are showing nothing.
and 3rdly the docker images command shows the following out put at my side
REPOSITORY TAG IMAGE ID CREATED SIZE
oracle/database 18.4.0-xe a347238232be 2 days ago 319MB
oraclelinux 7-slim 0a28ba78f4c9 7 weeks ago 132MB
but the forums I am following shows the the size which is quite different from my side.
REPOSITORY TAG IMAGE ID CREATED SIZE
oracle/database 18.4.0-xe 926f4349b277 12 minutes ago 5.89GB
oraclelinux 7-slim 153f8d73287e 8 weeks ago 131MB
Need suggesting and help needed here, thanks advance.
Regards,

Related

Exporting build files from docker container

I have a docker image that builds a c/c++ embedded project and creates build artifacts.
I wrote a shell script which builds the code by using the docker image. It is intended be launched by the user on his machine to do debugging.
The build process work just fine and the files are created, but I'm not able to export them to the host machine for debugging.
I'm getting the error:
Error: No such container:path: builder:/usr/src/myCppProject/build/*.elf
This is my script:
#!/bin/bash
echo "Building docker image"
docker build --tag my-gcc:1.0 .
echo "Running docker container"
docker run -t -d --name builder --privileged my-gcc:1.0
echo "extracting artifacts"
docker cp builder:/usr/src/myCppProject/build/*.elf .
echo "Removing container"
docker stop builder
docker rm builder
echo "Cleaning up"
docker rmi $(docker images -f "dangling=true" -q)
the detailed output is:
...
/usr/src/myCppProject/LIBS/Shell/shell.h:80:76: warning: missing braces around initializer [-Wmissing-braces]
80 | sConsoleCMD_td s##name __attribute__ ((section(".shell_cmds"))) = {"MAGIC", (uint8_t*)#name, (uint8_t*)basic_desciption, (uint8_t*)detailed_description, (uint32_t)param_count, false, 0, CallBack, {0,0}}
| ^
/usr/src/myCppProject/APPS/main.c:32:1: note: in expansion of macro 'CON_CREATE_CMD'
32 | CON_CREATE_CMD(test, "test", "", 1, NULL);
| ^~~~~~~~~~~~~~
[100%] Linking C executable Testbench.elf
text data bss dec hex filename
25536 2044 7680 35260 89bc Testbench.elf
[100%] Built target Testbench.elf
Removing intermediate container 3d4a78e05b33
---> 8f2bfcfd19d7
Step 16/17 : WORKDIR /usr/src/myCppProject/build
---> Running in fd30a67e6d93
Removing intermediate container fd30a67e6d93
---> 5f0104d0b1e7
Step 17/17 : RUN ls
---> Running in 6096737dd094
CMakeCache.txt
CMakeFiles
Makefile
Testbench.bin
Testbench.elf
Testbench.hex
Testbench.map
cmake_install.cmake
Removing intermediate container 6096737dd094
---> 3624660a131b
Successfully built 3624660a131b
Successfully tagged my-gcc:1.0
Running docker container
4a31aee944118084602841f51b317df21b49d831345d78e652e36a3b2dfd1801
extracting artifacts
Error: No such container:path: builder:/usr/src/myCppProject/build/*.elf
Removing container
builder
...
Trying to use volumes is even worse, when calling:
mkdir build
docker run --name builder --privileged -v /build:/usr/src/myCppProject/build my-gcc:1.0
The script finishes successfully but the folder build on the host is empty :-( In my understanding whatever is but into build folder in the container should be also present in the just created build folder on the Host.
Thanks in advance e for your help.
Martin
OK finally I found it:
docker cp builder:/usr/src/myCppProject/build/*.elf does not work. It seems you need to specify the exact name.

Dockerfile RUN lpadmin to add a printer not working in the built image?

I want to add a printer in Dockerfile RUN command, so this is my Dockerfile
FROM dassh/eline:base
MAINTAINER dassh
# start cups service is necessary to run lpadmin command
RUN service cups start && lpadmin -p VLM2601 -v EleanBackend:/tmp -m
VLM2601_gdi.ppd -E && echo done
Build procedure
docker build -t dassh/eline .
Sending build context to Docker daemon 722.9kB
Step 1/3 : FROM dassh/eline:base
---> 712dce8cd557
Step 2/3 : MAINTAINER dassh
---> Running in 2f3f5f80b665
Removing intermediate container 2f3f5f80b665
---> 2b53b81d6ff4
Step 3/3 : RUN service cups start && lpadmin -p VLM2601 -v EleanBackend:/tmp -m VLM2601_gdi.ppd -E && echo done
---> Running in f176fbdf765e
* Starting Common Unix Printing System cupsd
...done.
done
Removing intermediate container f176fbdf765e
---> e229e278b085
Successfully built e229e278b085
Successfully tagged dassh/eline:latest
The build was successful without any error. But when I started a container with this image, I found that the printer wasn't added.
dassh#ubuntu:~$ docker run -itd dassh/eline /bin/bash
a8785057e71a598cd391f355848819295fef8e311090f70cbae95ca5360856c2
dassh#ubuntu:~$ docker cp ~/123.pdf a8:/
dassh#ubuntu:~$ docker attach a8
root#a8785057e71a:/pdf_to_prn#
root#a8785057e71a:/pdf_to_prn# service cups start
* Starting Common Unix Printing System cupsd [ OK ]
root#a8785057e71a:/pdf_to_prn# lp -o fit-to-page -o media=A4 -d VLM2601 /123.pdf
lp: The printer or class does not exist.
The command returns an error that the printer does not exist, but when I execute add printer command in the container manually, and run lp command again, everything is fine.
root#a8785057e71a:/pdf_to_prn# lpadmin -p VLM2601 -v EleanBackend:/tmp -m VLM2601_gdi.ppd -E
root#a8785057e71a:/pdf_to_prn# lp -o fit-to-page -o media=A4 -d VLM2601 /123.pdf
request id is VLM2601-1 (1 file(s))
Therefore, my adding printer command has no issues. So what is happening?
The problem cause by use lpadmin create printer.
system get printers by file /etc/cups/printers.conf.
use lpadmin add a printer will generate or update file /etc/cups/printers.conf.
step 2 is asynchronous! (It takes almost 30s in my test after execute lpadmin command)
Dockerfile RUN this step complete before file /etc/cups/printers.conf generated.

Understanding the difference in sequence of ENTRYPOINT/CMD between Dockerfile and docker run

Docker noob here...
I am trying to build and run an IBM DataPower container from a Dockerfile, but it doesn't seem to work the same as when just running docker run and passing the same parameters in the terminal.
This works (docker run)
docker run -it \
-v $PWD/config:/drouter/config \
-e DATAPOWER_ACCEPT_LICENSE=true \
-e DATAPOWER_INTERACTIVE=true \
-e DATAPOWER_WORKER_THREADS=4 \
-p 9090:9090 \
--name mydatapower \
ibmcom/datapower
... the key part being that it mounts the ./config folder and the custom configuration is picked up by datapower running in the container.
This doesn't (Dockerfile)
Dockerfile:
FROM ibmcom/datapower
ENV DATAPOWER_ACCEPT_LICENSE=true
ENV DATAPOWER_INTERACTIVE=true
ENV DATAPOWER_WORKER_THREADS=4
EXPOSE 9090
COPY config/auto-startup.cfg /drouter/config/auto-startup.cfg
Build:
docker build -t local/datapower .
Run:
docker run -it \
-p 9090:9090 \
--name mydatapower local/datapower
The problem is that DataPower doesn't pick up the auto-startup.cfg file, so the additional config options doesn't get used. I know the source file path is correct because if I misspell the file name docker throws an error.
I have a theory that it might be running the inherited ENTRYPOINT or CMD before the config file is available. I don't know how to test or prove this. I don't know what the ENTRYPOINT or CMD is because the inherited image is not open source and I can't figure out how to find it.
Does that seem likely?
UPDATE:
The content of the auto-startup.cfg is:
top; co
ssh
web-mgmt
admin enabled
port 9090
exit
It simply enables the DataPower WebGUI.
The output when running it in the commandline with:
docker run -it -v $PWD/config:/drouter/config -v $PWD/local:/drouter/local -e DATAPOWER_ACCEPT_LICENSE=true -e DATAPOWER_INTERACTIVE=true -e DATAPOWER_WORKER_THREADS=4 -p 9091:9090 --name myconfigureddatapower ibmcom/datapower`
...contains this:
20170908T121729.015Z [0x8100006e][system][notice] : Executing startup configuration.
20170908T121729.970Z [0x00350014][mgmt][notice] web-mgmt(WebGUI-Settings): tid(303): Operational state up
...but with Dockerfile it doesn't. That's why I think the config files may be copied into place too late.
I've tried adding CMD ["/bin/drouter"] to the end of my Dockerfile to no avail.
I have tested your Dockerfile and it seems to be working. My auto-startup.cfg file is copied in the proper location and when I launch the container it's reading the file.
I get this output:
[root#ip-172-30-2-164 tmp]# docker run -ti -p 9090:9090 test
20170908T123728.818Z [0x8040006b][system][notice] logging target(default-log): Logging started.
20170908T123729.067Z [0x804000fe][system][notice] : Container instance UUID: 36bcca0e-6139-4694-91b0-2b7b66c3a498, Cores: 4, vCPUs: 4, CPU model: Intel(R) Xeon(R) CPU E5-2676 v3 # 2.40GHz, Memory: 16049.1MB, Platform: docker, OS: dpos, Edition: developers-limited, Up time: 0 minutes
20170908T123729.071Z [0x8040001c][system][notice] : DataPower IDG is on-line.
20170908T123729.071Z [0x8100006f][system][notice] : Executing default startup configuration.
20170908T123729.416Z [0x8100006d][system][notice] : Executing system configuration.
20170908T123729.417Z [0x8100006b][mgmt][notice] domain(default): tid(8143): Domain operational state is up.
708f98be1390
Unauthorized access prohibited.
20170908T123731.239Z [0x806000dd][system][notice] cert-monitor(Certificate Monitor): tid(399): Enabling Certificate Monitor to scan once every 1 days for soon to expire certificates
20170908T123731.552Z [0x8100006e][system][notice] : Executing startup configuration.
20170908T123732.436Z [0x8100003b][mgmt][notice] domain(default): Domain configured successfully.
20170908T123732.449Z [0x00350014][mgmt][notice] web-mgmt(WebGUI-Settings): tid(303): Operational state up
login:
To check that your file has been copied to the container you can run docker run -ti local/datapower sh to enter the container and then check the content of /drouter/config/.
Your base image command is: CMD ["/bin/drouter"] you can check it running docker history ibmcom/datapower.
UPDATE:
The drouter user in the container must be able to read the auto-startup.cfg file. You have 2 options:
set your local auto-startup.cfg with the proper permissions (chmod 644 config/autostart.cfg).
or add these line in the Dockerfile so drouter can read the file:
USER root
RUN chown drouter /drouter/config/auto-startup.cfg
USER drouter

How to save a Docker image

I'm trying to follow a tutorial on https://www.ctl.io/developers/blog/post/docker-networking-rules/, which contains the following:
As I understand it, the code
FROM ubuntu:trusty
MAINTAINER Laura Frank <laura.frank#centurylink.com>
CMD while true; do echo 'hello world' | nc -l -p 8888; done
Is the content of a Dockerfile, which can be put in a newly created, empty directory and build using the command docker build ..
I don't quite understand however how to 'name' the image no-exposed-ports? Am I supposed to use tagging (the -t option) as in the example in https://docs.docker.com/engine/tutorials/dockerimages/?
I believe that by 'naming' the Docker image it is indeed meant that you use a tag. I used the command
docker build -t no-exposed-ports .
which gives the following response:
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM ubuntu:trusty
---> 3f755ca42730
Step 2 : CMD while true; do echo 'hello world' | nc -l -p 8888; done
---> Using cache
---> b8a7551d0ed9
Successfully built b8a7551d0ed9
From the command docker images I can see that no-exposed-ports is the name of the REPOSITORY, and the default tag latest has been assigned:
REPOSITORY TAG IMAGE ID CREATED SIZE
no-exposed-ports latest b8a7551d0ed9 18 minutes ago 188 MB
Finally, running with the command
docker run -d --name no-exposed-ports no-exposed-ports
produces a long hash as in the example on the blog:
eb39d8ef68826510f4c964ad586ff04b9e334433538d9d69a39aa0ec44d6701f

How to test the container or image after docker build?

I have the following Dockerfile
############################################################
# Purpose : Dockerize Django App to be used in AWS EC2
# Django : 1.8.1
# OS : Ubuntu 14.04
# WebServer : nginx
# Database : Postgres inside RDS
# Python : 2.7
# VERSION : 0.1
############################################################
from ubuntu:14.04
maintainer Kim Stacks, kimcity#gmail.com
# make sure package repository is up to date
run echo "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) main universe" > /etc/apt/sources.list
run apt-get update
# install python
# install nginx
Inside my VM, I did the following:
docker build -t ubuntu1404/djangoapp .
It is successful.
What do I do to run the docker image?
Where is the image or container?
I have already tried running
docker run ubuntu1404/djangoapp
Nothing happens.
What I see when I run docker images
root#vagrant-ubuntu-trusty-64:/var/virtual/Apps/DockerFiles/Django27InUbuntu# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu1404/djangoapp latest cfb161605c8e 10 minutes ago 198.3 MB
ubuntu 14.04 07f8e8c5e660 10 days ago 188.3 MB
hello-world latest 91c95931e552 3 weeks ago 910 B
When I run docker ps, nothing shows up
You have to give a command your container will have to process.
Example : sh
you could try :
docker run -ti yourimage sh
(-ti is used to keep a terminal open)
If you want to launch a daemon (like a server), you will have to enter something like :
docker run -d yourimage daemontolaunch
Use docker help run for more options.
You also can set a default behaviour with CMD instruction in your Dockerfile so you won't have to give this command to your container each time you want to run it.
EDIT - about container removing :
Containers and images are different.
A container is an instance of an image.
You can run several containers from the same image.
The container automatically stops when the process it runs terminates.
But the container isn't deleted (just stopped, so you can restart it).
But if you want to remove it (removing a container doesn't remove the image) you have two ways to do :
automatically removing it at the end of the process by adding --rm option to docker run.
Manually removing it by using the docker rm command and giving it the container ID or its name (a container has to be stopped before being removed, use docker stop for this).
A usefull command :
Use docker ps to list containers. -q to display only the container IDs, -a to display even stopped containers.
More here.
EDIT 2:
This could also help you to discover docker if you didn't try it.
How to test the container or image after docker build?
In order to test you can add write a bash script which will do the job https://blog.brazdeikis.io/posts/docker-image-tests
Btw, from the post, I see that it does not match the question from the title.
So, Added a link for the souls who arrived here based on the title...
Download the latest shaded dist from https://github.com/dgroup/docker-unittests/releases:
wget https://github.com/dgroup/docker-unittests/releases/download/s1.1.1/docker-unittests-app-1.1.1.jar
De fine an *.yml file with tests.
version: 1.1
setup:
- apt-get update
- apt-get install -y tree
tests:
- assume: java version is 1.9, Debian build
cmd: java -version
output:
contains:
- openjdk version "9.0.1"
- build 9.0.1+11-Debian
- assume: curl version is 7.xxx
cmd: curl --version
output:
startsWith: curl 7.
matches:
- "^curl\\s7.*\\n.*\\nProtocols.+ftps.+https.+telnet.*\\n.*\\n$"
contains:
- AsynchDNS IDN IPv6 Largefile GSS-API
- assume: Setup section installed `tree`
cmd: tree --version
output:
contains: ["Steve Baker", "Florian Sesser"]
Run tests for image
java -jar docker-unittests.jar -f image-tests.yml -i openjdk:9.0.1-11
https://i.stack.imgur.com/DSv72.png

Resources