What is the equivalent of "docker logs" in containerd? - containerd

In docker we can view the logs of a container using "docker logs" command.
What will be the equivalent command in containerd ?
Thanks

Related

How to stop and start Docker container from bash script Synology?

Hey guys so I'm on a synology DS218+ and I'm running docker and hosting my own instance of gitlab in it.
So now I'm trying to write an update Script with bash.
docker stop gitlab_td3v
rm -rf /volume1/docker/"gitlab"
rm -rf /volume1/gitlab/"gitlab_backup.rb"
cp -r /volume1/gitlab /volume1/docker/"gitlab"
cp /volume1/gitlab/config/gitlab.rb /volume1/gitlab/"gitlab_backup.rb"
docker rm -f gitlab_td3v
docker pull gitlab/gitlab-ee:latest
docker run --detach --hostname Myhost.name --name gitlab_td3v --publish ..:.. --publish ..:.. --publish ..:.. --restart always --volume /volume1/gitlab/config:/etc/gitlab --volume /volume1/gitlab/data:/var/opt/gitlab --volume /volume1/gitlab/logs:/var/log/gitlab gitlab/gitlab-ee:latest
The problem I have now as you can see in the image I'm trying to stop and remove the container but It doesn't recognise it's name, but if I echo docker ps in the file it gives me the container with the name I used in the file.
CLI
Also when I just run the commands in the bash shell it works only as soon as I try to run the file it doesn't work and now I'm really confuse cause I made sure I'm on the same user on the same shell and everything and that I am but in the file it won't let me select the container over the name or the id I get from docker ps.
So now the question I guess is did anyone have the same problem or does anyone know a fix for it?
Would really appreciate it thanks.
The script must be executed as root.
docker stop CONTAINERNAME
CONTAINERNAME is definied by value "NAME"
See by
docker stats

How do I bind a volume in Windows docker?

I'm running Windows 2019 Server with latest docker.
I need to start a windows container, and bind the current C: to Z: in the container, but this does not work:
docker run -v c:\:z:\ -it XXX cmd.exe
What's the correct syntax?
EDIT
Here's what I've tried
PS C:\Users\Administrator> docker run --mount 'type="bind",source="C:\",target="Z:\"' -it mcr.microsoft.com/windows/nanoserver:1809 cmd.exe
invalid argument "type=bind,source=C:\",target=Z:\"" for "--mount" flag: parse error on line 1, column 19: bare " in non-quoted-field
See 'docker run --help'.
PS C:\Users\Administrator> docker run --mount type=bind,source=C:\,target=Z:\ -it mcr.microsoft.com/windows/nanoserver:1809 cmd.exe
docker: Error response from daemon: hcsshim::CreateComputeSystem 9b4e6759c82a071453bf4449f18dbbb2bd90511651c146a6e561a45771e0548c: The parameter is incorrect.
PS C:\Users\Administrator>
Did you try with mount syntax?
using Powershell:
docker run --mount 'type="bind",source="C:\",target="Z:\"' myimage:latest
or
Without quotes:
docker run --mount type=bind,source=C:\,target=Z:\ myimage:latest
I just got this to work:
docker run -p 80:80 -v //e/testdata/:/opt/testdata imagetag
On host windows: e:\testdata
mapped in container: /opt/testdata
To access e:\testdata one needs to put a double slash before the drive letter, and no colon there. I am mapping into a linux container so that is a normal unix style path. The software inside the container was able to read and write the windows files.

Docker exec -it <containerid> dir doesn't work. Why? How to get directory info?

I'm very new to docker.
Also I'm using Docker for Windows (ie Image and Container are for Windows OS).
I'm trying to get a list of all the folders and subfolders to resolve another issue I'm having. I read several post and blogs and seems like I should be able to run
docker exec -it <container id> dir
To get the info as it is suppose to allow me to run commands against the container.
I even ran
docker exec -it f83eb1533b67 help
which gave me a list of commands (because no one tells what are acceptable 'commands'...) and it is listed. however I get the following message when I run DIR command
PS P:\docker\tmp\SqlServerSetup> `docker exec -it f83eb1533b67 dir`
container f83eb1533b671b4462b8a1562da7343185b2dd27e94ff360e0230969d432ec37 encountered an error during CreateProcess: failure in a Windows system call: The system cannot find the file specified. (0x2)
[Event Detail: Provider: 00000000-0000-0000-0000-000000000000] extra info: {"CommandLine":"dir","WorkingDirectory":"C:\\","Environment":{"ACCEPT_EULA":"Y","attach_dbs":"[]","sa_password":"Pass1.4DBAs","sa_password_path":"C:\\ProgramData\\Docker\\secrets\\sa-password"},"EmulateConsole":true,"CreateStdInPipe":true,"CreateStdOutPipe":true,"ConsoleSize":[0,0]}
PS P:\docker\tmp\SqlServerSetup>
Please note: I don't want to persist a volume. Seems like that option is for people that are trying to reuse data.
UPDATE:
This is the statement that i'm using to create the container:
docker run -p 1433:1433 -e sa_password=Pass1.4DBAs -e ACCEPT_EULA=Y -p 11433:1433 --name sqlTraining --cap-add SYS_PTRACE -d microsoft/mssql-server-windows-developer
It works fine. Container is created, but I want to view the filesystem within that container.
For Windows containers, prefix the command with the command shell (cmd) and the /c parameter. For example:
docker exec <container id> cmd /c dir
This will execute the dir command on the specified container and terminate.
Try running:
docker exec -it <container id> sh
to start the interactive shell console. This should help you with debugging.

Jenkins console does not show the output of command runs on docker container

Running below command to execute my tests on docker container
sudo docker exec -i 6d49272f772c bash -c "mvn clean install test"
Above command running on Jenkins execute bash. But Jenkins console does not show the logs for test execution.
I had a similar problem with docker start (which is similar to docker exec). I used the -i option and it would work fine outside Jenkins, but the console in Jenkins didn't show any output from this command. I replaced -i with -a similar to the following:
sudo docker container create -it --name container-name some-docker-image some-command
sudo docker container start -a container-name
sudo docker container rm -f container-name
The docker exec method doesn't have a -a option so possibly removing the -i option would work too (since you are not interacting with the container in Jenkins), so if that doesn't work than you can convert to the following commands and achieve similar results with standard out being captured.

Docker exec in bash script

I'm creating dynamically docker containers via bash script:
while getopts ":s:d:h" opt; do
case $opt in
s)
for i in $(seq $2 $END);
do
docker run -dit --name=app_client_$i -d app:client
docker exec -d app_client_$i $app_start
done
;;
...
The docker container starts fine, but the docker exec command caused problems. When I try (without the -d):
docker exec app_client_$i $app_start
The application inside the docker container starts fine - but I'm attached to this docker container. I want to start the app inside the docker container in the background, so I use the -d parameter:
docker exec -d app_client_$i $app_start
With that the app doesn't start inside the docker container. What I am missing?
Okay, got it (facepalm):
With the docker -d you're going to start the process INSIDE the container in the background. So my app was already running inside the container, but in the background.
Cheers!

Resources