etcdctl: command not found - etcd

Hi I am using etcd version as follows
{"etcdserver":"3.2.7","etcdcluster":"3.2.0"}
I need to get the version history of the key but for me only curl command are working if I do
etcdctl get --prefix --rev=4 foo
I get:
-bash: etcdctl: command not found
I am able to run the etcdctl with v2 but with v3 I am getting this error.

on ubuntu machine run below to get etcdctl :
--
apt install etcd-client

You need to install etcd Binaries
]# wget "https://github.com/coreos/etcd/releases/download/v3.3.9/etcd-v3.3.9-linux-amd64.tar.gz"
]# tar -xvf etcd-v3.3.9-linux-amd64.tar.gz
]# sudo mv etcd-v3.3.9-linux-amd64/etcd* /usr/local/bin/
]# export ETCDCTL_API=3
Then you can execute your etcdl command
Eg:
]# /usr/local/bin/etcdctl --endpoints <EnpointIP>:<PORT> --cert=/<location>/<crt>.pem --key=/<location>/<keyFile>.pem --cacert=/<location>/ca.pem member list
How can I locate my cert file?
If ETCD running as a container follow the below step.
1. login to instance where ETCD running.
2. docker ps -a | grep etcd
3. docker inspect <ContainerID> | grep etc

Related

Docker gives `no such file or directory` on `docker run <image_id>`

So I've just created my very first docker image (woohoo) and was able to run it on the original host system where it was created (Ubuntu 20.04 Desktop PC). The image was executed using docker run -it <image_id>. The expected command (defined in CMD which is just a bash script) was run, and the expected output was seen. I assumed this meant I successfully created my very first docker image and so I pushed this to Docker Hub.
Docker Hub
GitHub repo with original docker-compose.yml and Dockerfile
Here's the Dockerfile:
FROM ubuntu:20.04
# Required for Debian interaction
# (https://stackoverflow.com/questions/62299928/r-installation-in-docker-gets-stuck-in-geographic-area)
ENV DEBIAN_FRONTEND noninteractive
WORKDIR /home/benchmarking-programming-languages
# Install pre-requisites
# Versions at time of writing:
# gcc -- version (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
# make -- GNU Make 4.2.1
# curl -- 7.68.0
RUN apt update && apt install make build-essential curl wget tar -y
# Install `column`
RUN wget https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v2.35/util-linux-2.35-rc1.tar.gz
RUN tar xfz util-linux-2.35-rc1.tar.gz
WORKDIR /home/benchmarking-programming-languages/util-linux-2.35-rc1
RUN ./configure
RUN make column
RUN cp .libs/column /bin/
WORKDIR /home/benchmarking-programming-languages
RUN rm -rf util-linux-2.35-rc1*
RUN apt install python3 pip -y
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN apt install default-jdk-headless -y
RUN apt install rustc -y
# Install GoLang
RUN wget https://go.dev/dl/go1.17.8.linux-amd64.tar.gz
RUN rm -rf /usr/local/go && tar -C /usr/local -xzf go1.17.8.linux-amd64.tar.gz
ENV PATH="/usr/local/go/bin:${PATH}"
# Install Haxe and Haxelib
RUN wget https://github.com/HaxeFoundation/haxe/releases/download/4.2.5/haxe-4.2.5-linux64.tar.gz
RUN tar xfz haxe-4.2.5-linux64.tar.gz
RUN ln -s /home/benchmarking-programming-languages/haxe_20220306074705_e5eec31/haxe /usr/bin/haxe
RUN ln -s /home/benchmarking-programming-languages/haxe_20220306074705_e5eec31/haxelib /usr/bin/haxelib
# # Install Neko (Haxe VM)
# RUN add-apt-repository ppa:haxe/snapshots -y
# RUN apt update
# RUN apt install neko -y
RUN if ! test -d /home/benchmarking-programming-languages; then mkdir /home/benchmarking-programming-languages && echo "Created directory /home/benchmarking-programming-languages."; fi
COPY . /home/benchmarking-programming-languages
RUN pip install -r /home/benchmarking-programming-languages/requirements_dev.txt
CMD [ "/home/benchmarking-programming-languages/benchmark.sh -v" ]
However, upon pulling the same image on my Windows 10 machine (same machine as above just dual booted) and a Windows 11 laptop using both the Docker Desktop application and the command line (docker pull mariosyian/benchmarking-programming-languages followed by docker run -it <image_id>). Both which give me the following error
Error invoking remote method 'docker-run-container': Error: (HTTP code 400) unexpected - failed to create shim: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/home/benchmarking-programming-languages/benchmark.sh -v": stat /home/benchmarking-programming-languages/benchmark.sh -v: no such file or directory: unknown
Despite this, running the image as a container with a shell (docker run -it <image_id> sh), I am successfully able to, not only see the file, but execute it with no errors! Can someone suggest a reason for why the error happens in the first place, and how to fix it?
In your Dockerfile you have specified the CMD as
CMD [ "/home/benchmarking-programming-languages/benchmark.sh -v" ]
This uses the JSON syntax of the CMD instruction, i.e. is an array of strings where the first string is the executable and each following string is a parameter to that executable.
Since you only have a single string specified docker tries to invoke the executable /home/benchmarking-programming-languages/benchmark.sh -v - i.e. a file named "benchmark.sh -v", containing a space in its name and ending with -v. But what you actually intended to do was to invoke the benchmark.sh script with the -v parameter.
You can do this by correctly specifying the parameter(s) as separate strings:
CMD ["/home/benchmarking-programming-languages/benchmark.sh", "-v"]
or by using the shell syntax:
CMD /home/benchmarking-programming-languages/benchmark.sh -v

command not found even when "which" shows its path with sudo

I'm on Fedora release 25 with zsh 5.2
I am trying to use a command with sudo. (In this example, docker-compose)
Problem:
which command shows where it is.
$ sudo PATH=$PATH which docker-compose
/usr/local/bin/docker-compose
In spite of that, command not found
$ sudo PATH=$PATH docker-compose
sudo: docker-compose: command not found
I could make it work by sudo `which docker-compose` but I want to know why this occurs.
What I tried:
I double-quoted PATH=$PATH but got the same result.
$ sudo "PATH=$PATH" docker-compose
sudo: docker-compose: command not found
/usr/local/bin/ is not on root path. Check with
sudo bash -c 'echo "$PATH"'
/usr/sbin:/usr/bin:/sbin:/bin
Use absolute path to the command.
Adding /usr/local/bin to root path seems to be a security risk.

Docker ERROR: Container command not found or does not exist when running from Win10

This is driving me crazy...
I have Win10 and I have installed the Docker Toolbox with
Docker=1.10.2
Compose=1.6.0
VirtualBox=5.0.14
I have successfully launched the LAMP in Linux [Amazon linux] but when I try to do the same the terminal responds with "ERROR: Container command not found or does not exist"
As I understand, there is something wrong with the way Windows interpreter the CMD syntax.
I have tried
- CMD ["/run.sh"]
- ENTRYPOINT ["/run.sh"]
- CMD /run.sh
- CMD '/run.sh'
- CMD run.sh
- CMD "/run.sh"
but nothing seems to work.
Note: When I run CMD /run.sh the error does not appear but the container exits immediately.
Note2: I have exactly the same problem when trying to setup the LAMP with Docker-Machine on AWS
I have this DockerfileLamp :
FROM ubuntu
# -- Install needed packages --
ENV DEBIAN_FRONTEND noninteractive
# -- Install additional utilities --
RUN apt-get update && \
apt-get install -y supervisor git curl apache2 mcrypt cron wget nano unzip
# -- Install PHP 5.5 --
RUN apt-get -y update && \
apt-get -y install php5 libapache2-mod-php5 mysql-server-5.5 php5-mysql pwgen php-apc php5-mcrypt php5-xdebug php5-gd php5-curl php-pear openssh-server php5-cli php5-apcu php5-intl php5-imagick php5-json
# -- Set localhost to apache conf file --
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
# -- Add image configuration and scripts --
ADD ./lamp/start-apache2.sh /start-apache2.sh
ADD ./lamp/start-mysqld.sh /start-mysqld.sh
ADD ./lamp/run.sh /run.sh
RUN chmod 755 /*.sh
ADD ./lamp/my.cnf /etc/mysql/conf.d/my.cnf
ADD ./lamp/supervisord-apache2.conf
/etc/supervisor/conf.d/supervisord-apache2.conf
ADD ./lamp/supervisord-mysqld.conf
/etc/supervisor/conf.d/supervisord-mysqld.conf
# -- Remove pre-installed database --
RUN rm -rf /var/lib/mysql/*
# -- Add MySQL utils --
ADD ./lamp/setup_MySQL.sh /setup_MySQL.sh
RUN chmod 755 /*.sh
# -- config to enable .htaccess --
##ADD apache_default /etc/apache2/sites-available/000-default.conf
RUN a2enmod rewrite
# -- Environmental variables to configure php --
ENV PHP_UPLOAD_MAX_FILESIZE 10M
ENV PHP_POST_MAX_SIZE 10M
# -- Add volumes for MySQL --
##VOLUME ["/etc/mysql", "/var/lib/mysql" ]
# -- Set up SSH server --
RUN mkdir /var/run/sshd
RUN echo 'root:root' |chpasswd
RUN sed -ri 's/^PermitRootLogin\s+.*/PermitRootLogin yes/'
/etc/ssh/sshd_config
RUN sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config
ADD ./lamp/supervisord-openssh-server.conf
/etc/supervisor/conf.d/supervisord-openssh-server.conf
# -- Install Python & pip --
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y python python-pip python-dev && \
pip install --upgrade pip
# -- Install xvfb --
RUN apt-get install -y xvfb
EXPOSE 80 3306 22
CMD /run.sh
and the run.sh :
#!/bin/bash
VOLUME_HOME="/var/lib/mysql"
sed -ri -e "s/^upload_max_filesize.*/upload_max_filesize = ${PHP_UPLOAD_MAX_FILESIZE}/" \
-e "s/^post_max_size.*/post_max_size = ${PHP_POST_MAX_SIZE}/" /etc/php5/apache2/php.ini
if [[ ! -d $VOLUME_HOME/mysql ]]; then
echo "=> An empty or uninitialized MySQL volume is detected in $VOLUME_HOME"
echo "=> Installing MySQL ..."
mysql_install_db > /dev/null 2>&1
echo "=> Done!"
/setup_MySQL.sh
else
echo "=> Using an existing volume of MySQL"
fi
exec supervisord -n
and the docker-compose.yml :
lamp: # apache + mysql/php
build: .
dockerfile: DockerfileLamp
ports:
- "8181:80" # open apache to public
- "3333:3306" # open mysql to public
- "2222:22" # open SSH to public
Docker is process centric, in other words your containers dies when your CMD script dies. At the end of your script run ...
tail -f logfile (where logfile is some logfile you are interested in)
This will
1 - stop your container exiting
2 - allow you to do
docker logs -f containerName
To help u debug
3 - allow you to enter into the container with
docker exec -it bash containerName
Then u can run the command that you think is failing inside the container and try n sort this out
Whilst this doesn't directly answer your question it should give u sufficient weaponry to attack this issue
For another project I tried to get to work on Windows with Docker Machine I ran into the same ambiguous error message of docker-compose Container command not found or does not exist.
Your comment about line endings triggered me to try dos2unix ./*/*.sh within git-bash (multiple scripts, in subfolders), which fixed the issue for me.
My suspicion is that git clone saves the files with DOS line endings, which results in incorrect syntax for the top line !#/bin/bash.
$ docker-compose -v
docker-compose version 1.6.2, build e80fc83
$ docker version
Client:
Version: 1.10.3
API version: 1.22
Go version: go1.5.3
Git commit: 20f81dd
Built: Thu Mar 10 21:49:11 2016
OS/Arch: windows/amd64
Server:
Version: 1.10.3
API version: 1.22
Go version: go1.5.3
Git commit: 20f81dd
Built: Thu Mar 10 21:49:11 2016
OS/Arch: linux/amd64
I solved it by simplifying the file. I commented out all the controls because whatever I tried it would keep throwing Syntax Errors
#!/bin/bash
VOLUME_HOME="/var/lib/mysql"
sed -ri -e "s/^upload_max_filesize.*/upload_max_filesize = ${PHP_UPLOAD_MAX_FILESIZE}/" \
-e "s/^post_max_size.*/post_max_size = ${PHP_POST_MAX_SIZE}/" /etc/php5/apache2/php.ini
#if [[ ! -d $VOLUME_HOME/mysql ]]; then
echo "=> An empty or uninitialized MySQL volume is detected in $VOLUME_HOME"
echo "=> Installing MySQL ..."
mysql_install_db > /dev/null 2>&1
echo "=> Done!"
/setup_MySQL.sh
#else
# echo "=> Using an existing volume of MySQL"
#fi
exec supervisord -n
It works for my case so I am not going to investigate further. Cheers!
EDITED
The above solution was not so complete.
It worked because I was making changes from INSIDE the container.
The permanent solution goes like this :
I migrated the run.sh file to a private Gist . [It does not need to be private but ok]
I think the problem is that when I try to build the Dockerfile from Windows machine [either locally or on a cloud provider] it messes up the syntax , EOF , line breaks and whatnot.
So I broke out of it by ADDing the gist url
ADD http://gist_url/run.sh /run.sh
Note1: You must use the raw file URL otherwise you are going to get the complete HTML.
Note2: The private gist is not protected.You don't need authentication to fetch the URL.

How to install docker man pages on Mac os

I've installed docker on mac os as written in documentation.
But in some docs (for example in the docker book) I see the recomendations to use man docker-run (man docker-pull, etc).
But when I run such command I get the error:
bessarabov#bessarabov-osx:~$ man docker
No manual entry for docker
How can I install docker man-documentation to my Mac OS system?
As of 2017.06.01, you have to git checkout your desired tag/version from
version >= 17.06: https://github.com/docker/docker-ce
version < 17.06: https://github.com/moby/moby
and then, go to the components/cli directory and execute:
make -f docker.Makefile manpages
To add the manpages to the manpath:
echo "MANPATH $PWD/man" | sudo tee -a /private/etc/man.conf
Source: https://github.com/docker/cli/issues/217
It looks like docker has slightly changed since #Sergiy's answer. Here is a slightly updated version that worked for me.
git clone https://github.com/docker/docker.git
cd docker/man # looks like the directory has moved up
docker build -t docker/md2man . # don't forget the '.'
docker run -v $PWD/:/docs:rw -w /docs -i docker/md2man /docs/md2man-all.sh
sudo cp -R man* /usr/share/man/ # you'll likely need sudo access for this
man docker # check it worked
Until the issue is resolved you can build man pages manually via a docker container using the supplied Dockerfile and then just copy generated files to /usr/share/man/:
# Step 1: checkout docker sources, but make sure you do this
# somewhere in /Users directory because boot2docker can only
# share this path with docker containers
git clone https://github.com/docker/docker.git
# Step 2: build docker image
cd docker/docs/man
docker build -t docker/md2man .
# Step 3: build man pages
docker run -v /Users/<path-to-git-dir>/docker/docs/man:/docs:rw \
-w /docs -i docker/md2man /docs/md2man-all.sh
# Step 4: copy generated man pages to /usr/share/man
cp -R man* /usr/share/man/
Enjoy!
It seems the go/glide bits under the hood of docker/md2man have changed since #gilly's answer. What I ended up doing, on Mac OS:
cd /usr/local
git clone https://github.com/docker/docker.git
brew install ruby
gem install md2man
cd docker/man
mkdir man1; for i in *.1.md; md2man-roff $i > man1/${i%.md}; done
cd /usr/local/share/man/man1
for i in ../../../docker/man/man1/*.1; do ln -s $i .; done

Why is sudo: bundle command not found?

Why is command "bundle" not found when using sudo:
[root#desktop gitlab]# sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
sudo: bundle: command not found
[root#desktop gitlab]#
but does exist when not using sudo:
[root#desktop gitlab]# bundle exec rake gitlab:setup RAILS_ENV=production
Warning
You are running as user root, we hope you know what you are doing.
Things may work/fail for the wrong reasons.
For correct results you should run this as user git.
This will create the necessary database tables and seed the database.
You will lose any previous data stored in the database.
Do you want to continue (yes/no)? no
Quitting...
[root#desktop gitlab]#
The reason I ask is I am following https://github.com/gitlabhq/gitlab-recipes/tree/master/install/centos, and it states to use sudo.
I've tried adding a -i flag as described by Using $ sudo bundle exec ... raises 'bundle: command not found' error, but get "This account is currently not available.".
Check if the PATH has the same values both with and without sudo. Apparently it cannot find bundle just because it is not listed in PATH
You can compare the outputs of following two lines
$ echo 'echo $PATH' | sh
$ echo 'echo $PATH' | sudo sh
Ideally sudo is supposed to leave PATH untouched. But this might be a side issue of your hosting distribution.
Edit by original poster. Output is:
[root#desktop etc]# echo 'echo $PATH' | sh
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root#desktop etc]# echo 'echo $PATH' | sudo sh
/sbin:/bin:/usr/sbin:/usr/bin:/user/local/bin
[root#desktop etc]#
The user was created without a bash login shell. Change this in centos using system-config-users. Then su git into /home/git and move to gitlab directory. Execute the bundle commands without the sudo tag. The next error you will encounter is the missing database.yml in the config dir. fix this with the correct password (i.e. copy the mysql or postgres sample and edit).
I had this issue I thought that my gitlab installed from source and I got same error. but after try Omnibus method for backup my issue solved
with this command:
sudo gitlab-rake gitlab:backup:create
Try :
sudo -u git -H env PATH=$PATH && bundle exec rake gitlab:check RAILS_ENV=production
to use the same PATH than current user.

Resources